JustBought.it HTTP API Documentation
Searching
You can search for posts using the the API. Simply access this url: http://justbought.it/api/search.php| Parameter | Name | Required |
|---|---|---|
| q | The text to search for in the post | true |
| rpp | The number of results to be returned per page, defaults to 20 | false |
| page | The number of the page to be returned, defaults to 1 | false |
Here is a simple example of using this API function:
http://justbought.it/api/search.php?q=test&page=1&rpp=2
Favourites
You can get the favourites for a user using this url: http://justbought.it/api/favourites.php| Parameter | Description | Required |
|---|---|---|
| username | The username of the user | true if user_id is not supplied |
| user_id | The user_id of the user | true if username is not supplied |
| rpp | The number of results to be returned per page, defaults to 20 | false |
| page | The number of the page to be returned, defaults to 1 | false |
Here is a simple example of using this API function:
http://justbought.it/api/favourites.php?username=user0&page=1&rpp=2
Posts
You can get the posts for a user using this url: http://justbought.it/api/posts.php| Parameter | Description | Required |
|---|---|---|
| username | The username of the user | true if user_id is not supplied |
| user_id | The user_id of the user | true if username is not supplied |
| rpp | The number of results to be returned per page, defaults to 20 | false |
| page | The number of the page to be returned, defaults to 1 | false |
Here is a example of using this API function:
http://justbought.it/api/posts.php?username=user0&page=1&rpp=2
JSON Format
The following is an example of the JSON return from API calls
{"results":
[{"id":"1896",
"guid":"w9y7",
"what":"I #cantdecide me testing with a clean copy of the db, deployment is near!",
"tweet":"I #cantdecide me testing with a clean copy of the db, deployment is near! in Melbourne AU http:\/\/jb.ly\/w9y7",
"location":"Melbourne AU",
"rating":null,
"votesfor":null,
"views":"3",
"producturl":"",
"categories":"",
"created_at":"2009-11-09 10:59:41",
"time_since":"1 day ago",
"user":{
"id":"1388",
"username":"user0",
"personname":"James Cole",
"gender":"M",
"avatar_url":"http:\/\/someurl\/somepic.jpg",
"status":"Rookie",
"status_icon_url":"images\/star.png"
},
"assets":[{
"id":"251",
"thumbnail_url":"http:\/\/justbought.it\/dev\/assets\/yq85d4_s.jpg",
"full_url":"http:\/\/justbought.it\/dev\/assets\/yq85d4.jpg",
"vote_count":"0"
},
{
"id":"252",
"thumbnail_url":"http:\/\/justbought.it\/dev\/assets\/3rg92a_s.jpg",
"full_url":"http:\/\/justbought.it\/dev\/assets\/3rg92a.jpg",
"vote_count":"1"}],
"comments":[{
"id":"132",
"user_id":"1388",
"user_name":"user0",
"user_image":null,
"text":"test http:\/\/jb.ly\/w9y7",
"created_at":"2009-11-10 07:05:16",
"time_since":"17 hours ago"
},
{
"id":"131",
"user_id":"1388",
"user_name":"user0",
"user_image":null,
"text":"test http:\/\/jb.ly\/w9y7",
"created_at":"2009-11-10 07:02:24",
"time_since":"17 hours ago"
}]
},
,"total_rows":"14",
"pages":7}
JSON Error Format
The following is an example of the JSON return from API calls which fail with an error
{"error":"Some error message"}
Making Posts
In order to make posts on JustBought.it via the API you must first register here
Once registered you will receive and API Key, you can then use this key to request access to a JustBought.it user account.
The callback page will be passed the new user connection key. The connection key is returned via the GET variable and is 50 characters long. This connection key can then be stored in your database and is passed into requests made to the API. There is no expiry on the connection key.
To gain access to a users account you must to the following:
- Direct the user to this URL: http://justbought.it/apiconnect.php?apikey=yourApiKey
- Once the user has entered their login info they will be redirected to the callback url you specified during api registration.
- On the callback page save the returned connection key.
- Pass the connection key in with API requests.
You can now pass requests to http://justbought.it/api/add.php.
here is a php curl example of making a post
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_URL, "http://justbought.it/api/add.php");
curl_setopt($ch, CURLOPT_POST, true);
$post = array(
"upload_pic"=>"@chartly_logo.png",
"what"=>"I #testing test123",
"connectionkey"=>"an4x2fn6eqqba647wtz56q5kw2y6bcxp2faxfx28mzs7az7hyd5zd8ycg3va539zd6g88rgag5cwqqp9kafcabs29twx76am87sc",
"producturl"=>"http://some product url"
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
echo $response;
Once a post has been made JSON in the following format will be returned:
{
"id":"1898",
"guid":"mcsk",
"what":"I #testing test123",
"tweet":"I #testing test123 in Collingwood, VIC http:\/\/jb.ly\/mcsk",
"location":"Collingwood, VIC",
"rating":null,
"votesfor":null,
"views":0,
"producturl":"http:\/\/justbought.it",
"categories":null,
"created_at":1258341266,
"time_since":"1 sec ago",
"user":{
"id":"1388",
"username":"user0",
"personname":"James Cole",
"gender":"M",
"avatar_url":"http:\/\/external.ak.fbcdn.net\/safe_image.php?logo&d=1af76ea65d2afff22f1255adbaaeebe8&url=http%3A%2F%2Fprofile.ak.fbcdn.net%2Fv229%2F1613%2F0%2Fq665056548_9975.jpg&v=5",
"status":"Rookie",
"status_icon_url":"images\/star.png"
},
"assets":[
{
"id":"254",
"thumbnail_url":"http:\/\/justbought.it\/dev\/assets\/dqc4fg_s.png",
"full_url":"http:\/\/justbought.it\/dev\/assets\/dqc4fg.png",
"vote_count":"0"
}]
,"comments":[]
}
| Parameter | Description | Required |
|---|---|---|
| connectionkey | Your user specific connectionkey | true |
| upload_pic | The picture to be displayed with the post | false |
| upload_pic2 | The picture to be displayed with the post, only supply if you want to make a comparison post | false |
| what | the actual post, must be less than 100 characters | true |
| lat | The lattitude of the post, if lat and lng are not supplied the user's profile location will be used | false |
| lng | The longitude of the post, if lat and lng are not supplied the user's profile location will be used | false |
| producturl | The product URL for the "Buy Now" button. | false |
My Location:
Edit Location
Find Local Friends
Get Our iPhone App