Deezer api - get more than 400 songs from a playlist? - deezer

I'm trying to use Deezer API and when I use GET "http://api.deezer.com/playlist/(some_playlist_id)/tracks", I only get the first 400 songs from the playlist. (in reality, there are around 900 songs)
Is it possible to somehow get a list of ALL the songs in a playlist?
Thanks in advance,
Martin

Most of the time, large lists in Deezer API are split in several page to avoid using too much network at a time.
If you look in the json result, you'll see it looks like this :
{
"checksum": "c468607e7bb46ddae60548860b76c6b1",
"data": [ /* ... lots of tracks here ... */ ],
"next": "http://api.deezer.com/playlist/821789631/tracks?index=50",
"total": 879
}
You can use the "next" url to fetch the next page, which will in turn include the next page link.

Related

Get photo from post using Facebook graph API

I am attempting to display the latest post from a public Facebook page on a website using the graph API.
Using the following URL, I am able to get the latest posts data:
https://graph.facebook.com/MYPAGENAME/posts?access_token=MYACCESSTOKEN
Which returns:
{
"data": [
{
"story": "MYPAGENAME added a new photo.",
"created_time": "2017-08-20T19:00:00+0000",
"id": "MYID"
}
...
The post in question displays on the Facebook page with a photo included, but there is not 'photo' object (or anything similar) returned in the API data. How do I access the picture URL for this post? Thanks in advance.
This request will fetch posts and the media information for the first image for each post.
/posts?fields=attachments{media}?access_token=YOUR_ACCESS_TOKEN
Sometimes posts contain multiple images. If you'd like to support that you need to fetch the subattachments also:
/posts?fields=attachments{subattachments{media}}?access_token=YOUR_ACCESS_TOKEN
Note that this method usually only provides image URLs that are up to 720px wide. If you want higher resolution imagery, you need to access data[0].attachments.data[0].subattachments.data[0].target.id to get the actual image ID which you can then use to perform an additional query /IMAGE_ID_HERE?fields=images to obtain the higher resolution image. Increment the numbers to get additional posts and images inside each post.

Facebook Api v2.2 - get album's photos shares count

I'm using the following Graph Api query in order to receive the likes and comments counts on all the photos in an Album inside my page:
https://graph.facebook.com/v2.2/album_id?fields=photos.limit(250){likes.limit(1),comments.limit(1),id,source},likes.limit(1)&access_token=my_access_token
I want to to also receive each one of these pictures shares count, but the share count is not connected to the photo end point, Its connected to the page_story_id.
So, in order to receive all the shares count i'm going to need to query each of those individually, which doesn't make sense when you have an album with 200 pictures (not to mention an album with 500 pictures).
FQL is deprecated after v2.1 so I can't use the FQL to get this (which will defiantly ease everything for me).
Isn't there an easier way to do so?
Update
Thanks to #CBroe comments, this is my batch:
[
{
"method":"GET",
"name":"get-photos",
"relative_url":"951337131548012?fields=photos.limit(250){likes.limit(1),comments.limit(1),id,source,page_story_id},likes.limit(1)"
},
{
"method":"GET",
"relative_url":"/?ids={result=get-photos:$.photos.data.*.page_story_id}"
}
]
Now it does return all the photos post objects, but how can I query them all the specific field? like add ?fields=shares
ok after struggling with this for few hours, and thank to #CBroe help I found the right batch request for my needs and it involves both batch and Graph API multiple requests.
[
{
"method":"GET",
"name":"get-photos",
"relative_url":"951337131548012?fields=photos.limit(250){likes.limit(1),comments.limit(1),id,source,page_story_id},likes.limit(1)"
},
{
"method":"GET",
"relative_url":"/?ids={result=get-photos:$.photos.data.*.page_story_id}&fields=shares"
}
]
by adding &fields=shares i'm filtering the fields of inner results of the multi request.
Hope it helps someone :)

How to get Facebook Insights data of photo feed using Graph API?

Insights API works properly for link feed but it doesn't work for photo feed. For photo feed, Insights API returns 0 or empty even though Insights page shows a high reach and engagement rate.
Here is the url pattern of my photo feed:
https://www.facebook.com/[PAGE]/photos/a.xxx.xxx.[PAGE ID]/[POST ID]/
Insights API returns:
{
"id": "[PAGE ID]_[POST ID]/insights/post_story_adds_by_action_type_unique/lifetime",
"name": "post_story_adds_by_action_type_unique",
"period": "lifetime",
"values": [
{
"value": [
]
}
],
"title": "Lifetime Talking About This (Post) by action type",
"description": "Lifetime: The number of unique people who created a story about your Page post by interacting with it. (Unique Users)"
}
I've been struggeling with the same questions... one thing I can tell you is, that you most likely used a wrong id for you photo post.
Please ensure that you ONLY use ID's retrieved by a facebook api. So this is a sample process:
1. Note your page-id
2. Use GRAPH to query <url-to-graph>/<page_id>/feed?access_token=<your_token>
3. From the response, take the photo-post-id you want to analyze
4. Use GRAPH to query <url-to-graph>/<id_from_step_3>/insights/?access_token=<your_token>
5. Check the metrics returned from step 4 and enjoy!
Please keep in mind that there's an undocumented need to add your page_id to any post_id. So every replacement of {post-id} as it is written in the FB api's will be _.
Hope that helps...

Interfacing with wall/feeds

This is the first time I'm trying to develop a facebook app so sorry in advance if my question is too naive.
What I need to do is making a chat-like facebook application where:
the user can write something on the wall
the app should be able to detect this event and send an HTTP request to an external web service of my own which will provide a response (text)
publish that text as a comment
the user should be able to continue the dialog by entering another comment(s) (in which case we go back to step #2)
Basically, this would be very similar to:
https://www.facebook.com/SkyscannerFlightSearch
I think one (ugly) way to do this would be making a script which searches for new wall entries/comments and posts replies in an infinite loop by using the Graph API but it's obviously sub-optimal and expensive.
Is there any way to have facebook call a certain url every time a wall post/comment is entered?
Or maybe something like Twitter's streaming API based on long-polling technique?
Am I in the right direction by assuming such kind of solutions or I'm totally missing the point?
Thanks in advance.
Giampaolo
I am working on something very similar myself.
So far i have the "loop" which can be set to any page, group or app on facebook.
SAMPLE: https://shawnsspace.com/plugins/wallfeed.php My page wall.
SAMPLE: https://shawnsspace.com/plugins/wallfeed.php?pageid=19292868552&ptype=feed&limit=40 Facebook Platform Wall.
With some perms, a form and user access_tokens i can make the wall postable. Asper UGLY - you do not need to run this in a loop, Facebook supports realtime updates and will send a response to your app when a user, or page has made a change.
MORE: http://developers.facebook.com/docs/api/realtime
Thanks for the input.
I tried to use the real-time API by using object=user and fields=feed.
If I understood the doc correctly this should result in my callback url being called (POST) every time a user writes something on my app's wall.
I received the initial GET request but never POST.
This is the current configuration:
{
"data": [
{
"object": "user",
"callback_url": "http://XXX.XXX.XXX.XX:8888/",
"fields": [
"feed"
],
"active": true
},
{
"object": "page",
"callback_url": "http://XXX.XXX.XXX.XX:8888/",
"fields": [
"picture"
],
"active": true
}
]
}
I've noticed various user comments reporting different concerns about the reliability of this API.
Also, here:
http://developers.facebook.com/docs/reference/api/page/
it says: "Note: Real-time updates are not yet supported for the total number of Page checkins."
...which I'm not sure what it means exactly.
For the record, my app's page I'm using for tests is:
http://www.facebook.com/pages/testgiamp/187148861354102?sk=wall

Why do I get this error when I try to access a certain type of object via the Facebook Graph API?

I have a user, user_2. There is a post on their wall, made by user_1.
The URL is
https://www.facebook.com/user_1/posts/10150166228506188
I try to get the content using the Graph API, with this request:
https://graph.facebook.com/10150166228506188?access_token=ACCESSTOKENUSER_2
I get this error:
{
"error": {
"type": "GraphMethodException",
"message": "Unsupported get request."
}
}
The access_token I am using is good, because requests to get things like statuses & images work fine:
https://graph.facebook.com/10150233707783933?access_token=ACCESSTOKENUSER_2
Result:
{
"id": "10150233707783933",
"from": {
"name": "American Steel",
"category": "Professional sports team",
"id": "203692078932"
},
"tags": {
"data": [
etc
The error seems to happen whenever I try to get items that have this kind of URL:
https://www.facebook.com/username/posts/item_id
The permissions my app has include these:
Why is this error occurring?
I think that, in order to access the posts directly through the graph api, you have to prepend the user id to the post id you see in the facebook url.
So in your example the facebook post url is :
https://www.facebook.com/user_1/posts/10150166228506188
And you try to get through the graph api :
https://graph.facebook.com/10150166228506188?access_token=ACCESSTOKENUSER_2
BUT you should be doing :
https://graph.facebook.com/{id of user_1}_10150166228506188?access_token=ACCESSTOKENUSER_2
I noticed that all posts ids are formed like this by visiting :
https://graph.facebook.com/me/posts?access_token=...
Does this solve your problem ?
You're accessing the end-point of the post incorrectly. Every object on Facebook has a unique ID. Right now, it just so happens that they form it by appending different IDs together (your post is an example, <user_id>_<post_id>, and for a comment on that post it'd be <user_id>_<post_id>_<comment_id>). Facebook hasn't made public acknowledgment of this (not that they really have to, it's obvious) which makes me leary to rely on that paradigm for accessing data within the graph. This is because Facebook could change it at any point, and the fact that they haven't said "yeah append these 2 ids together and you can get something meaningful from this part of the graph" means they won't have to notify anyone about the change, you could just wake up one day and your app be completely broken and you'd have to find a work around quickly and while suffering down time.
The graph api works by accessing objects on Facebook by making a request to the API for that unique ID. So, you don't need to access (and can't access) your posts by going to graph.facebook.com/<user_id>/posts/<post_id>. Instead, you go to graph.facebook.com/<post_id>. You get the post_id from the /<user_id>/home or /<user_id>/feed end-point on the graph. There is no need to modify a post_id in order to fetch information about it from the graph.
Hope that helps