Shared albums is a quite new feature of Facebook.
I'm encountering an issue with the Graph API while trying to publish photos to a shared album. The issue is actually related to the ID of the album.
As user A, I create an album getting the ID 1 and I add user B as contributor.
As user B, I can retrieve the album 1 using the Graph API but the "can_upload" flag is set to "false". Which prevents contributor B to upload photos to this album.
When I try to get the album's information as user B using facebook.com, it looks like the album has a different ID than 1, let's call it 2. When I retrieve album information as user B using ID 2 with Graph API, the "can_upload" flag is correctly showing "true".
Apparently the original's album ID is known as a different ID to album contributors. But how can I find out the ID allowing contributors to upload photos to it?
As there seems to be no API call to retrieve the ID (2) of the album to be used while publishing as contributor (user B), this is how one can manage to get it:
As user B (contributor), get the info of the album using its original
ID (1). Make sure to include field "cover_photo" in the request.
Get the info of the cover photo, using its ID retrieved above. Make
sure to include the field "link" in the request. Parse the "link"
field in order to retrieve the value of the parameter "set" which
contains the album ID.
Get the album ID by extracting it from the value above. The format is
something like "a.1234567890" or "a.1234567890.2345678901" where the
contributor's album ID (2) would be 1234567890.
Related
If my app uses the graph api to retrieve the id of a particular photo, will that id always exist as long as the photo it refers to is not modified/deleted out of the users albums?
Yes, node/object IDs like the photo id in your case are unique and will exist as long as the photo isn't deleted.
I get shared story feed with graph api.
In The result I have fields like :
type": "photo",
"status_type": "shared_story",
"object_id": "647332045296931"
the object_id is the photo object.
I need the post_id of that photo.
How can I get the post id with graph api from that point ?
Thanks
Using fql get page_story_id(Please refer to https://developers.facebook.com/docs/reference/fql/photo):
Retrieve the page_story_id details:
Access the exact page at www base facebook using this page_story_id(replace underscore with "/posts/"):
The post_id can get via https://graph.facebook.com/420619404634864/feed too:
Or fql:
Updates:
For video, it is easier compare with photo type to find post_id from object_id.
As you can see on the screenshot, concate page id "155483697799865" and object id "4320084459885" with underscore is equal to post_id "155483697799865_4320084459885":
Let's visit the story page using these post_id(Again, replace underscore with "/posts/"):
To be clarify, what i answer is get original post_id for this object id, not post_id of share status.
For example, i share a video from coca-cola fan page, the object id 12345 get from "me/feed" is same with object id 12345 get from "coca-cola/feed", which point to the same video. However, the post_id is different. My answer is help you to find out original story post_id (coca-cola upload a video), not the shared post_id(xxx Shared coca-cola's video)
Cheers
I'm playing around w/ the /me/music.listens endpoint of Graph API and I have it working just fine. Except I can't seem to figure out how to get actual artist info to come back. I see the song and even the album (though that seems a little inconsistent too). But never any artist info.
Check the developer explorer here: https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fmusic.listens
No artist info. Is this just not returned? I can't see how to specify this in a fields param list. FB's documentation of the actions is spotty at best so I figured I'd try here.
Thanks!
I've figured out a work around. It doesn't look like Facebook actually returns artist info. So you have to use the Spotify Lookup Service (http://developer.spotify.com/technologies/web-api/lookup/).
To break it down a little further, you start by pulling the music.listens feed from FB and you'll get info that looks like:
(
[song] => Array
(
[id] => 381659191902248
[url] => http://open.spotify.com/track/**2Vv27Gc5k5GgGW9jgtj1CS**
[type] => music.song
[title] => Follow Through
)
)
From there, you need to grab the bolded track ID.
Lastly, fetch the song metadata with this call to Spotify: http://ws.spotify.com/lookup/1/.json?uri=spotify:track:2Vv27Gc5k5GgGW9jgtj1CS
You'll be returned the album name, artist info, etc.
If someone knows a better way, lemme know!
You can retrieve artists informations on graph API with the song id :
https://graph.facebook.com/song_id?fields=data{musician}
ex : https://graph.facebook.com/697975930266172?fields=data{musician}
Old question I know, but you can retrieve related information such as both the song title and artist title in the same request using Graph API's 'field expansion'.
For example - Last 10 songs
me?fields=music.listens.limit(10){data{song{title,id},musician{id,title}}}
To retrieve more information from either the song or musician entities just tweak the fields requested.
Note, this requires user_actions.music permission
This is not a duplicate of How can I get the interests of my friend through facebook api?. user_interests permission (to access /me/interests) is useless (if not deprecated) Facebook feature that hardly ever returns any data.
Instead, I am referring to the data aggregated by Facebook at this page:
These are all user likes grouped into categories like "Music", "Books", "TV Shows", etc. Generally, user likes can be retrieved through /me/likes. However, the latter query returns a rather vivid array of categories.
Is there a way to get user likes categorised into the same generic categories like Facebook does?
https://developers.facebook.com/docs/reference/api/user/:
The User object has the following connections:
books: The books listed on the user's profile.
games: Games the user has added to the Arts and Entertainment section of their profile.
movies: The movies listed on the user's profile.
music: The music listed on the user's profile.
television: The television listed on the user's profile.
The fields favorite_athletes and favorite_teams are deprecated, though. Not sure, if there will be any replacement for these analog to the above connections – or if users are just supposed to normally “like” the fan pages of athletes/teams in the future.
My approach to this issue is to process the API data within my application as such:
'Books' => array('Fictional Character', 'Writer', 'Book', 'Author', 'Book Store', 'Library', 'Magazine'),
'Films' => array('Actor/Director', 'Movie', 'Producer', 'Studio', 'Movie Theater', 'TV/Movie Award', 'Fictional Character', 'Movies/Music'),
[..]
e.g., if user likes "Writer" or "Book", I assign the like to "Books" category.
However, this solution is not ideal as Facebook might change category names, add new names, etc.
In fact, I want to get the cover photo for each user's albums.
So, first I get the albums data:
$albums = $GLOBALS["facebook"]->api("/me/albums",'GET');
Then I retrieve the cover_photo id and ask API to get details about this photo (such as the source)
foreach($albums as $album) {
$data = $GLOBALS["facebook"]->api("/". $album["cover_photo"], 'GET');
}
But this make a lot of calls to the API (one per album) and it's seems that she doesn't like.. Because my application return a timeout error.
Is there another way to do what I want?
Thanks.
You can always use the Batch API, or just use FQL. Something like the below would retrieve the src of all the album covers of the current user:
SELECT src
FROM photo
WHERE pid IN (
SELECT cover_pid
FROM album
WHERE owner = me()
)
You can try it here. Obviously you can choose any field to retrieve from the photo table.