How to get more than 350 favorites with SoundCloud API? - soundcloud

I have about 600 likes on my soundcloud (my profile: https://soundcloud.com/bogem/likes) and I try to get full list of my likes.
But I can't get more than 300 favorites:
$ curl 'https://api.soundcloud.com/users/75306957/favorites?client_id=HIDDEN&limit=150&offset=300'
{"errors":[{"error_message":"403 - Forbidden"}]}
Even authorised:
$ curl 'https://api.soundcloud.com/me/favorites?client_id=HIDDEN&limit=150&oauth_token=HIDDEN&offset=300'
{"errors":[{"error_message":"403 - Forbidden"}]}
What do I do wrong or is there any limits?

You'll need to use the linked_partitioning pagination method which will return you a collection object that contains your likes, and a next_href that gives you the URL to paginate to.
There's a blog post about dropping support for offset-based pagination.

Related

Get ads and their image in the same query

I'm using the graph API and trying to get a list of ads with their insights and post images.
I don't want to do multiple queries for this as I quickly hit the "(#17) User request limit reached" issue even when I use batch queries.
My current query looks like this:
/ACCOUNT_ID_HERE/ads?fields=insights{cpc,reach,spend,clicks,ctr},status,creative
Now in order to get the post image, I need to take the creative ID that is returned and use it in another query to pull the post like this:
/CREATIVE_ID/?fields=object_story_id
Then use the returned story id to pull the picture like:
/OBJECT_STORY_ID/?fields=picture
Is there any way I can combine these queries to do less requests?
Something like:
/ACCOUNT_ID_HERE/ads?fields=insights{cpc,reach,spend,clicks,ctr},status,creative{object_story_id{picture}}'
Any help is appreciated. Thanks.
Facebook's Batch API may work for you. It allows for multiple Graph API calls to be made from a single HTTP request and supports dependencies between those requests. Read over the documentation for details and here's a example curl call of how it might work (I've not executed this call so please review against the API documentation and test).
curl \
-F 'access_token=...' \
-F 'batch=[
{
"method":"GET",
"name":"ads",
"relative_url":"/ACCOUNT_ID_HERE/ads?fields=insights{cpc,reach,spend,clicks,ctr},status,creative",
},
{
"method":"GET",
"name":"creative",
"relative_url":"/{result=ads:$.data.*.creative}/?fields=object_story_id"
},
{
"method":"GET",
"relative_url":"/{result=creative:$.data.*.object_story_id}/?fields=picture"
}
]' \
https://graph.facebook.com

Facebook Graph API returning 25 pages only, How to increase it's limit?

I getting data using:
get('/me?fields=id,name,email,picture,accounts', access_token);
But it is only returning 25 pages and returns a NEXT url to get the remainings. Is there any way I can put the limit=100 attribute in the above code?
get('/me?fields=id,name,email,picture,accounts&limit=100', access_token);
Or, better use paging: https://developers.facebook.com/docs/graph-api/using-graph-api/#paging

GitHub Api: User followers - paging?

I am playing with some Javascript and Github API, and I've came to one problem.
Each time, when I try to call for followers of any user who has followers, the callback that I get from the server shows only 30 users. For example:
https://api.github.com/users/vojtajina/followers - 30 followers
and user followers from original website:
https://github.com/vojtajina/followers - 1,039 followers
My questions is - what is going on? There is no 'next page' in the callback from the server. How can I get all of his/hers followers in the callback?
The max number of items per page is 100, so using the per_page=100 querystring parameter will increase the result to have 100 users per page:
https://api.github.com/users/vojtajina/followers?per_page=100
Using the page querystring parameter, you have control to pagination. For example, to get the second page, you should add page=2:
https://api.github.com/users/vojtajina/followers?per_page=100&page=2
If you want to get all the followers you have to iterate the pages until you receive an empty array.
If you want to use this into a Node.js / JavaScript (on client) app, you can use gh.js–a library I developed which handles this:
var GitHub = require("gh.js");
var gh = new GitHub({
token: "an optional token"
});
gh.get("users/vojtajina/followers", { all: true } function (err, followers) {
console.log(err || followers); // do something with the followers
});

Facebook share count from debugger page

How can I get number of shares that is shown on facebook debugger page via API?
I've empirically found it to fit the most for comparing with share counters from some others social networks, but it looks like this number does not show up anywhere except that debugger page.
Here are some details.
By now I've found 3 API calls that return somewhat relevant data:
via graph API: http://graph.facebook.com/?id=http%3A%2F%2Farzamas.academy%2Fspecial%2Fruslit
via FQL: https://graph.facebook.com/fql?q=SELECT%20url,%20normalized_url,%20share_count,%20like_count,%20comment_count,%20total_count,commentsbox_count,%20comments_fbid,%20click_count%20FROM%20link_stat%20WHERE%20url=%27http%3A%2F%2Farzamas.academy%2Fspecial%2Fruslit%27
via some old API: https://api.facebook.com/method/links.getStats?urls=http%3A%2F%2Farzamas.academy%2Fspecial%2Fruslit&format=json
The values in second and third call are identical, for my test url http://arzamas.academy/special/ruslit the current ones are
share_count: 492, like_count: 5042, comment_count: 491, total_count: 6025
The counter from the first call is named shares and is equal to total_count from second and third call.
When you paste the url in facebook debugger and click 'Show existing scrape information', one of the first rows in table is
Canonical URL: http://arzamas.academy/special/ruslit (6025 likes, 1635 shares)
Number of likes is equal to total_count from API calls, but how can I get that 1635 shares number via API?
I've found that specifying Graph API version newer than 2.0 gives another number (share.share_count), for some reason it is the sum of both numbers, that are shown in debugger (likes + shares).
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=%3Fid%3Dhttp%253A%252F%252Farzamas.academy%252Fspecial%252Fruslit&version=v2.3&
So now I can get counters from two calls and subtract to get the value that I need. There are obvious cons for this method:
2 calls
token requirement
looks not very reliable
But it should work, I'll try to implement it and will mark this answer as correct if there are no additional caveats and until there is no better solution.

Not getting retweets in response for statuses/friends_timeline twitter API Method

Hi I am using MGTwitterEngine & when request for tweets of my followers I am not getting the tweets which are retweeted.
According to the twitter documentation :
include_rts When set to either true, t or 1,the timeline will contain native retweets (if they exist) in addition to the standard stream of tweets. The output format of retweeted tweets is identical to the representation you see in home_timeline. Note: If you're using the trim_user parameter in conjunction with include_rts, the retweets will still contain a full user object.
I am also doing that. but no change in response.
My request is : https://twitter.com/statuses/friends_timeline/xyz.xml?include_rts=true&page=4&count=20
xyz is username.
I cannot figure out what's missing? Help
Try:
https://api.twitter.com/1/statuses/user_timeline.xml?include_rts=true&page=4&count=20&screen_name=xyz
Note the leading "api."