|
|
|||||||||||||||||
| hitta allt du behöver på Annonsera.se | |||
|
• Annonsera.se
» Documentation
» Annonsera API
What is Annonsera API?Annonsera API is very simple and flexible mechanism which allows users to acquire various information about advertisements directly from Annonsera.se and then display it somewhere in the Internet (personal web-pages, blogs, company websites and so forth). How to use Annonsera API?There are several ways to obtain and display information you are interested in:
Usage of Annonsera API via library of predefined widgetsOrdinary users who are not familiar with web-technologies can in a very simple manner gain benefits from using predefined set of widgets which were specially developed for quick setup and easy usage. We host a number of sample widgets. Such widgets may be easily customized and used at your website(s). Just try_it! It is very easy (basically it only takes several minutes to select, customize and setup desired widget).
Usage of Annonsera API via HTTP requestsIf you are an advanced WEB user (or developer) then you can obtain required information by means of Annonsera API calls. In order to continue deeper Annonsera API consideration it is required to get acquainted with a couple of terms. Annonsera API Call - HTTP request of special format which is charge of information retrieval from Annonsera.se. Actually typical Annonsera API Call is an URL like bellows: http://www.annonsera.se/api/SPACE/NAME.FORMAT[?PARAM_1=VALUE_1[&PARAM_N=VALUE_N]] where:
Annonsera API format - format in which data is sent upon request. Currently there are 3 formats supported:
Response formatsThere are samples of responses in different formats below. JSONWith JSON format any method can accept an additional request parametercallback- a JavaScript callback function. http://www.annonsera.se/api/ad/get.json?callback=displayAd&iad=21866
displayAd({
"ad":{
"id":21866,
"title":"Audi TT",
"text":"Audi TT",
"publisher":"Daniel",
"category":"FORDON\/Bilar",
"region":"V\u00e4stra G\u00f6taland",
"city":"G\u00f6teborg",
"person":"p",
"term":"1 m\u00e5nad",
"type":"S\u00e4ljes",
"price":85000,
"actual":"Y",
"expired":"Fri, 07 Aug 2009 10:20:41 +0200",
"expired_unixtime":1249633241,
"URL":"http:\/\/www.annonsera.se\/v%C3%A4stra-g%C3%B6taland-g%C3%B6teborg\/fordon-bilar\/audi-tt.html",
"images":[
{
"imageURL":"http:\/\/www.annonsera.se\/images\/00001\/0\/audi-tt.jpg",
"thumbnailURL":"http:\/\/www.annonsera.se\/images\/00001\/1\/audi-tt.jpg",
"height":425,
"width":640
}
]
}
})
There is a very simple example of callback function displayAd available. Please, check it (ad.js) if you are intrested in more detailed examples of usage and how to render simple widget using Annonsera API. XMLhttp://www.annonsera.se/api/ads/get.xml?category=fordon&count=1
<?xml version="1.0" encoding="UTF-8"?>
<ads>
<item>
<ad>
<id>93765</id>
<title>Gammal båtmotor</title>
<name>Gammal båtmotor</name>
<text>Renoveringsobjekt för intresserade. kom med bud.</text>
<publisher>Jennifer Andersson</publisher>
<category>FORDON/Båtdelar & tillbehör</category>
<categoryId>15</categoryId>
<region>Örebro</region>
<regionId>29</regionId>
<city>Örebro</city>
<cityId>149</cityId>
<person>p</person>
<term>3 månader</term>
<type>Säljes</type>
<price>0</price>
<actual>Y</actual>
<published>Thu, 26 Aug 2010 16:20:57 +0200</published>
<publishedUnixtime>1282832457</publishedUnixtime>
<expired>Sat, 27 Nov 2010 15:20:57 +0100</expired>
<expired_unixtime>1290867657</expired_unixtime>
<expiredUnixtime>1290867657</expiredUnixtime>
<URL>http://www.annonsera.se/%C3%B6rebro-%C3%B6rebro/fordon-b%C3%A5tdelar-_-tillbeh%C3%B6r/gammal-b%C3%A5tmotor.html</URL>
<url>http://www.annonsera.se/%C3%B6rebro-%C3%B6rebro/fordon-b%C3%A5tdelar-_-tillbeh%C3%B6r/gammal-b%C3%A5tmotor.html</url>
<images>
<item>
<id>78912</id>
<url>http://www.annonsera.se/images/00093/0/gammal-btmotor.jpg</url>
<thumbUrl>http://www.annonsera.se/images/00093/1/gammal-btmotor.jpg</thumbUrl>
<imageURL>http://www.annonsera.se/images/00093/0/gammal-btmotor.jpg</imageURL>
<thumbnailURL>http://www.annonsera.se/images/00093/1/gammal-btmotor.jpg</thumbnailURL>
<width>360</width>
<height>480</height>
</item>
</images>
</ad>
</item>
</ads>
RSShttp://www.annonsera.se/api/ads/get.rss?category=fordon&count=1
<rss version="2.0">
<channel>
<title>GG RSS</title>
<description>GG RSS</description>
<link>http://www.annonsera.se/api/ads/get.rss?category=fordon&count=1</link>
<copyright>InnovateIt.com</copyright>
<docs>http://cyber.law.harvard.edu/rss/rss.html</docs>
<generator>GAPI</generator>
<language>sv</language>
<lastBuildDate>Thu, 26 Aug 2010 14:28:23 GMT</lastBuildDate>
<pubDate>Thu, 26 Aug 2010 14:28:23 GMT</pubDate>
<ttl>15</ttl>
<item>
<title>Gammal båtmotor</title>
<description>Renoveringsobjekt för intresserade. kom med bud.</description>
<link>http://www.annonsera.se/%C3%B6rebro-%C3%B6rebro/fordon-b%C3%A5tdelar-_-tillbeh%C3%B6r/gammal-b%C3%A5tmotor.html</link>
<author>Jennifer Andersson</author>
<guid>http://www.annonsera.se/%C3%B6rebro-%C3%B6rebro/fordon-b%C3%A5tdelar-_-tillbeh%C3%B6r/gammal-b%C3%A5tmotor.html</guid>
<pubDate>Thu, 26 Aug 2010 16:28:23 +0200</pubDate>
</item>
</channel>
</rss>
Annonsera API errors handlingWhenever errors are occured Annonsera API provides you with meaningful information regarding what actually happen so you can deal with it according to your policy of handling errors. Errors are returned exactly in the same format the request was sent. Below listed example requests that contain errors. Bad parameters are underlined. JSONhttp://www.annonsera.se/api/ad/get.json?callback=displayAd&adId=XYZ displayAd({"error":{"code":400,"text":"invalid parameter: adId"}})
XMLhttp://www.annonsera.se/api/ads/get.xml?category=nonexistent&count=1
<?xml version="1.0" encoding="UTF-8"?>
<error>
<code>400</code>
<text>invalid parameter: category</text>
</error>
RSShttp://www.annonsera.se/api/ads/get.rss
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>Annonsera RSS</title>
<description>Annonsera RSS</description>
<link>http://www.annonsera.se/api/ads/get.rss</link>
<copyright>InnovateIt.com</copyright>
<docs>http://cyber.law.harvard.edu/rss/rss.html</docs>
<generator>GAPI</generator>
<language>sv</language>
<lastBuildDate>Tue, 07 Jul 2009 09:28:48 GMT</lastBuildDate>
<pubDate>Tue, 07 Jul 2009 09:28:48 GMT</pubDate>
<ttl>15</ttl>
<item>
<title>error 400</title>
<description>unsufficient paramters set for request</description>
<author>GAPI</author>
<pubDate>Tue, 07 Jul 2009 11:28:48 +0200</pubDate>
</item>
</channel>
</rss>
AuthorizationFor services that require authorization OAuth 1.0a must be used. Request token URLhttp://www.annonsera.se/oauth/request_token Authorize URLhttp://www.annonsera.se/oauth/authorize Access token URLhttp://www.annonsera.se/oauth/access_token Consumer key and consumer secretConsumer key and consumer secret can be obtained by creating a new application or you can list already created applications. Signing requestsRequests must be signed with HMAC-SHA1 signature method.
API CallsList categorieshttp://www.annonsera.se/api/categories/list Returns list of categories of one level (without children). AuthenticationNot required. Arguments
Exampleshttp://www.annonsera.se/api/categories/list.json?parentCategory=BOSTAD
{
"categories": [
{
"id": 110,
"name": "Utland",
"url": "http://www.annonsera.se/bostad-utland/"
},
{
"id": 111,
"name": "Tomter & Gårdar",
"url": "http://www.annonsera.se/bostad-tomter-_-g%C3%A5rdar/"
},
{
"id": 112,
"name": "Fritidshus",
"url": "http://www.annonsera.se/bostad-fritidshus/"
}
]
}
http://www.annonsera.se/api/categories/list.json?withChildren=1
{
"categories": [
{
"id": 10,
"name": "BOSTAD",
"url": "http://www.annonsera.se/bostad/",
"children": [
{
"id": 110,
"name": "Utland",
"url": "http://www.annonsera.se/bostad-utland/"
},
{
"id": 111,
"name": "Tomter & Gårdar",
"url": "http://www.annonsera.se/bostad-tomter-_-g%C3%A5rdar/"
},
{
"id": 112,
"name": "Fritidshus",
"url": "http://www.annonsera.se/bostad-fritidshus/"
}
]
},
{
"id": 11,
"name": "FORDON",
"url": "http://www.annonsera.se/fordon/",
"children": []
},
{
"id": 12,
"name": "ELEKTRONIK",
"url": "http://www.annonsera.se/elektronik/",
"children": []
}
]
}
List regionshttp://www.annonsera.se/api/regions/list Returns list of regions. AuthenticationNot required. ArgumentsNone. Exampleshttp://www.annonsera.se/api/regions/list.json
{
"regions": [
{
"id": 10,
"name": "Norrbotten",
"url": "http://www.annonsera.se/norrbotten/"
},
{
"id": 11,
"name": "Västerbotten",
"url": "http://www.annonsera.se/v%C3%A4sterbotten/"
},
{
"id": 12,
"name": "Jämtland",
"url": "http://www.annonsera.se/j%C3%A4mtland/"
}
]
}
List citieshttp://www.annonsera.se/api/cities/list Returns list of cities. AuthenticationNot required. Arguments
If specified, then list of cities from that region will be returned. Otherwise list of all cities will be returned. Exampleshttp://www.annonsera.se/api/cities/list.json?region=Norrbotten
{
"cities": [
{
"id": 110,
"name": "Kiruna",
"url": "http://www.annonsera.se/norrbotten-kiruna/"
},
{
"id": 111,
"name": "Pajala",
"url": "http://www.annonsera.se/norrbotten-pajala/"
},
{
"id": 112,
"name": "Jokkmokk",
"url": "http://www.annonsera.se/norrbotten-jokkmokk/"
}
]
}
Post adhttp://www.annonsera.se/api/ads/new Posts a new ad. AuthenticationRequired OAuth. HTTP methodPOST. Arguments
ExamplesExample result:
{
"ad": {
"id": "86476",
"name": "Utebord + 4 stolar",
"url": "http://www.annonsera.se/uppsala-uppsala/hem-_-hush%C3%A5ll-tr%C3%A4dg%C3%A5rd/utebord-4-stolar.html"
}
}
Get Adhttp://www.annonsera.se/api/ad/get Get ad info. AuthenticationNot required. Arguments
Examples
http://www.annonsera.se/api/ad/get.json?adId=21866
{
"ad":{
"id": 21866,
"name": "Audi TT",
"text": "Audi TT",
"publisher": "Daniel",
"category": "FORDON\/Bilar",
"categoryId": 12,
"region": "V\u00e4stra G\u00f6taland",
"regionId": 34,
"city": "G\u00f6teborg",
"cityId": 45,
"person": "p",
"term": "1 m\u00e5nad",
"type": "S\u00e4ljes",
"price": 85000,
"actual": "Y",
"published": "Tue, 07 Jul 2009 08:20:41 +0200",
"publishedUnixtime": 1246954841,
"expired": "Fri, 07 Aug 2009 10:20:41 +0200",
"expiredUnixtime": 1249633241,
"url":" http:\/\/www.annonsera.se\/v%C3%A4stra-g%C3%B6taland-g%C3%B6teborg\/fordon-bilar\/audi-tt.html",
"youtubeVideo":{
"code":"Pnc4AoLoQn0",
"url":"http:\/\/www.youtube.com\/watch?v=Pnc4AoLoQn0",
"thumbnailURL":"http:\/\/www.annonsera.se\/yi\/Pnc4AoLoQn0.jpg"
},
pdf":{
"url":"http:\/\/www.annonsera.se\/uploads\/00001\/0\/audi-tt.pdf ",
"thumbnailURL":"http:\/\/s3.annonsera.se\/img\/pdf.png"
},
"images":[
{
"id": 12,
"url": "http:\/\/www.annonsera.se\/images\/00001\/0\/audi-tt.jpg",
"thumbUrl": "http:\/\/www.annonsera.se\/images\/00001\/1\/audi-tt.jpg",
"width": 640,
"height": 425
}
]
}
}
List adshttp://www.annonsera.se/api/ads/get List ads. AuthenticationNot required. But if OAuth used then will be listed only ads of current user. Arguments
Exampleshttp://www.annonsera.se/api/ads/get.json?count=2
{ "ads" : [
{ "ad" : {
"actual" : "Y",
"category" : "FORDON/Mopeder",
"categoryId" : 18,
"city" : "Boden",
"cityId" : 47,
"expired" : "Fri, 17 Jun 2011 11:52:17 +0200",
"expiredUnixtime" : 1308304337,
"id" : 80444,
"name" : "API_test_2",
"person" : "p",
"phone" : "9876",
"price" : 25,
"published": "Tue, 07 Jul 2009 08:20:41 +0200",
"publishedUnixtime": 1246954841,
"publisher" : "Ronald McDonald",
"region" : "Norrbotten",
"regionId" : 1,
"term" : "6 månader",
"text" : "update_Desc_1",
"type" : "Säljes",
"url" : "http://www.annonsera.se/norrbotten-boden/fordon-mopeder/api-test-2.html"
} },
{ "ad" : {
"actual" : "Y",
"category" : "FORDON/Mopeder",
"categoryId" : 18,
"city" : "Boden",
"cityId" : 47,
"expired" : "Tue, 07 Dec 2010 12:30:16 +0100",
"expiredUnixtime" : 1291721416,
"id" : 80442,
"name" : "API_test_1",
"person" : "p",
"price" : 25,
"published": "Tue, 07 Jul 2009 08:20:41 +0200",
"publishedUnixtime": 1246954841,
"publisher" : "John_Smith",
"region" : "Norrbotten",
"regionId" : 1,
"term" : "6 månader",
"text" : "API_test_1_desc",
"type" : "Säljes",
"url" : "http://www.annonsera.se/norrbotten-boden/fordon-mopeder/api-test-1_0002.html"
} }
] }
Update adhttp://www.annonsera.se/api/ads/update Update existing ad. AuthenticationRequired OAuth. Arguments
Exampleshttp://www.annonsera.se/api/ads/update.json?adId=86476&price=400&showPhone=1 Returns an empty success response if it completes without error.
Update ad statushttp://www.annonsera.se/api/ads/updateStatus Set new status for ad. AuthenticationRequired OAuth. Arguments
Exampleshttp://www.annonsera.se/api/ads/updateStatus.json?adId=86476&active=1 Returns an empty success response if it completes without error.
Prolong adhttp://www.annonsera.se/api/ads/prolong Prolong existing ad. AuthenticationRequired OAuth. Arguments
Exampleshttp://www.annonsera.se/api/ads/prolong.json?adId=86476&term=6 Returns an empty success response if it completes without error. Add images to adhttp://www.annonsera.se/api/ads.images/add Add new images to existing ad. AuthenticationRequired OAuth. HTTP methodPOST. Arguments
Exampleshttp://www.annonsera.se/api/ads.images/add.json?adId=86476&images[]={encodedBinaryData1}&images[]={encodedBinaryData2}
Returns URLs of added images.
{
"images": [
{
"id": 10,
"url": "http://www.annonsera.se/images/00001/0/audi-tt-0001.jpg",
"thumbUrl": "http://www.annonsera.se/images/00001/1/audi-tt-0001.jpg",
"width": 600,
"height": 400
},
{
"id": 11,
"url": "http://www.annonsera.se/images/00001/0/audi-tt-0002.jpg",
"thumbUrl": "http://www.annonsera.se/images/00001/1/audi-tt-0002.jpg",
"width": 500,
"height": 250
}
]
}
Get ad imagehttp://www.annonsera.se/api/ads.images/get Get image info. AuthenticationRequired OAuth. ArgumentsimageId (Optional) ID of image uploaded by you. Exampleshttp://www.annonsera.se/api/ads.images/get.json?imageId=10
{
"image": {
"id": 10,
"url": "http://www.annonsera.se/images/00001/0/audi-tt-0001.jpg",
"thumbUrl": "http://www.annonsera.se/images/00001/1/audi-tt-0001.jpg",
"width": 600,
"height": 400
}
}
List ad imageshttp://www.annonsera.se/api/ads.images/list Returns list of ad images. AuthenticationRequired OAuth. Arguments
Exampleshttp://www.annonsera.se/api/ads.images/list.json?adId=86476
{
"images": [
{
"id": 10,
"url": "http://www.annonsera.se/images/00001/0/audi-tt-0001.jpg",
"thumbUrl": "http://www.annonsera.se/images/00001/1/audi-tt-0001.jpg",
"width": 600,
"height": 400
},
{
"id": 11,
"url": "http://www.annonsera.se/images/00001/0/audi-tt-0002.jpg",
"thumbUrl": "http://www.annonsera.se/images/00001/1/audi-tt-0002.jpg",
"width": 500,
"height": 250
}
]
}
Delete images from adhttp://www.annonsera.se/api/ads.images/delete Delete images from ad. AuthenticationRequired OAuth. Arguments
Exampleshttp://www.annonsera.se/api/ads.images/delete.json?adId=86476&imageIds=10;11 Returns an empty success response if it completes without error. Mail advertiserhttp://www.annonsera.se/api/ads/mailAdvertiser Post message to ad owner (advertiser). AuthenticationRequired captcha. Arguments
Exampleshttp://www.annonsera.se/api/ads/mailAdvertiser.json?{captcha_params}&adId=86476&email=john@example.com&name=John+Smith&message=Cool+ad!
Returns an empty success response if it completes without error.
User profile. Createhttp://www.annonsera.se/api/profile/new Create user profile. AuthenticationRequired captcha. Arguments
Exampleshttp://www.annonsera.se/api/profile/new.json?{captcha_params}&email=john@example.com&password=123456&name=John+Smith&address=London
{
"profile": {
"id": 3456
}
}
User profile. Gethttp://www.annonsera.se/api/profile/get Get info about user profile. AuthenticationRequired OAuth. ArgumentsNone. Exampleshttp://www.annonsera.se/api/profile/get.json
{
"profile": {
"id": 3456,
"email": "john@example.com",
"name": "John Smith",
"address": "London",
"type": "person",
"allowNotices": 1
}
}
User profile. Updatehttp://www.annonsera.se/api/profile/update Update user info. AuthenticationRequired OAuth. Arguments
Exampleshttp://www.annonsera.se/api/profile/update.json?name=John+Smith&address=Hollywood Returns an empty success response if it completes without error. User profile. Change passwordhttp://www.annonsera.se/api/profile/changePassword Change user password. AuthenticationRequired OAuth. Arguments
Exampleshttp://www.annonsera.se/api/profile/changePassword.json?currentPassword=123456&newPassword=qwerty Returns an empty success response if it completes without error. User profile. Change emailhttp://www.annonsera.se/api/profile/changeEmail Change user email. AuthenticationRequired OAuth. Arguments
Exampleshttp://www.annonsera.se/api/profile/changeEmail.json?currentEmail=123456@example.com&newEmail=qwerty@example.com Returns an empty success response if it completes without error.
Subscriptions. Annonsera newshttp://www.annonsera.se/api/subscriptions.news/update Subscribe or unsubscribe to/from Annonsera news. AuthenticationRequired OAuth. Arguments
Exampleshttp://www.annonsera.se/api/subscriptions.news/update.json?subscribe=1 Returns an empty success response if it completes without error.
Subscriptions. Createhttp://www.annonsera.se/api/subscriptions/new Create new subscription. AuthenticationRequired OAuth. Arguments
Exampleshttp://www.annonsera.se/api/subscriptions/new.json?categoryId=110&adTypes=sell;rent&periodicity=86400
{
"subscription": {
"id": 23,
"name": "Sell, Rent in category FORDON/Bilar, every day",
"category": "FORDON/Bilar",
"categoryId": 110,
"adTypes": "sell;rent",
"periodicity": 86400
}
}
Subscriptions. Gethttp://www.annonsera.se/api/subscriptions/get Get subscription info. AuthenticationRequired OAuth. Arguments
Exampleshttp://www.annonsera.se/api/subscriptions/get.json?subscriptionId=23
{
"subscription": {
"id": 23,
"name": "Sell, Rent in category FORDON/Bilar, every day",
"category": "FORDON/Bilar",
"categoryId": 110,
"adTypes": "sell;rent",
"periodicity": 86400
}
}
Subscriptions. Listhttp://www.annonsera.se/api/subscriptions/list List all subscriptions. AuthenticationRequired OAuth. ArgumentsNone. Exampleshttp://www.annonsera.se/api/subscriptions/list.json
{
"subscriptions": [
{
"id": 23,
"name": "Sell, Rent in category FORDON/Bilar, every day",
"category": "FORDON/Bilar",
"categoryId": 110,
"adTypes": "sell;rent",
"periodicity": 86400
},
{
"id": 45,
"name": "Buy in city Norrbotten/Pajala, every hour",
"city": "Norrbotten/Pajala",
"cityId": 56,
"adTypes": "buy",
"periodicity": 3600
},
{
"id": 67,
"name": "Sell, Buy, Rent related to "Utebord + 4 stolar", every week",
"ad": "Utebord + 4 stolar",
"adId": 86476,
"adTypes": "sell;buy;rent",
"periodicity": 7200
}
]
}
Subscriptions. Updatehttp://www.annonsera.se/api/subscriptions/update Update subscription. AuthenticationRequired OAuth. Arguments
Exampleshttp://www.annonsera.se/api/subscriptions/update.json?subscriptionId=23&adTypes=buy&periodicity=3600 Returns an empty success response if it completes without error.
Subscriptions. Deletehttp://www.annonsera.se/api/subscriptions/delete Delete subscription(s). AuthenticationRequired OAuth. Arguments
Exampleshttp://www.annonsera.se/api/subscriptions/delete.json?subscriptionIds=23 Returns an empty success response if it completes without error.
Using of captcha
Indeed captcha ID is ID of PHP session. Request new captcha sessionhttp://www.annonsera.se/api/captcha/new No authentication required.
Example response:
{
"captcha": {
"id": "ca83eec01e85ccfce435ff8b0cd172e7",
"imageUrl": "http://www.annonsera.se/captcha.html?captchaId=d801036882a46484a80e8ae74d8c0b59"
}
}
Captcha paramsTo execute method that requires captcha such parameters must be posted:
Client Libraries and SamplesAnnonsera PHP API - API wrapper classes in PHP with samples of calls made to API. Got a Question?Contact us at clientapi@annonsera.se See also | |||
|
|||
|
|
|||