Facebook sdk How can I get url from photo id - facebook

I use FBRequestConnection to get photo's id and post id
But I want to know the photo's URL
How can I do ?
I did use [FBRequest requestForGraphPath:id] , but no URL return
Thanks for help

Usually url's of image posts returned with every graph object but if you want to get profile image
"http://graph.facebook.com/" + id + "/picture"
Where id can be profile id or user name .e.g.
http://graph.facebook.com/jansharkhan/picture

Related

Get Another User's Information by Facebook Graph API

Hello I am new at facebook graph API
when I used url like this
https://graph.facebook.com/v2.7/me?fields=id,website,about,first_name,last_name,gender,birthday,education,age_range,email,%20television,movies,hometown,context,devices,favorite_teams,work&access_token=EAAM...
I can get website, first name , gender etc of me
but when I try to get another user's information from this url
https://graph.facebook.com/v2.7/{user id}?fields=id,website,about,first_name,last_name,gender,birthday,education,age_range,email,%20television,movies,hometown,context,devices,favorite_teams,work&access_token=EAAM...
I can get null values expect first_name, last_name and id
How can I correct the mistake?
Note : the other user allows to show this info.
Thanks

get facebook photo like count,share count,comment count

I writting a service that collect this counter of facebook posts. Users enter posts link, and then i get from the link the postID, and by using this FQL:
"SELECT like_info.like_count, comment_info.comment_count, share_count FROM stream WHERE post_id='xxx_xxxx' AND created_time > 01/04/2014 AND created_time < 02/04/2014 limit 1000",
I get this counters.
The problem I have is when user enter a link to facebook photo (for example: http://www.facebook.com/photo.php?fbid=10152281007419070&set=a.39727214069.46046.633269069&type=1&stream_ref=10),
then how do I get the postID? I know that the useriD is the number after the second dot in the link, but how do i get the other number?
Thanks in advance.
The post id in the url you have mentioned is the 101522....... ie just after fbid=
So, you can parse the url string and fetch the photoid

upload picture on timeline album of user using facebook c# sdk

I want to upload picture to timeline of user or page.
I am able to upload picture to users wall but it has created new album with my application name. But i want to upload picture to timeline album of user.
I have uploaded picture using bellow code
var result = client.Post("/"+ id +"/photos", postparameters);
I solved it.I just filtered id of the album where I wanted to post picture & passed it in place if "id" of above code.
var result = client.Post("/"+ album_id +"/photos", postparameters);
you can get album id dynamic :
dynamic albums = app.Get("me/albums");
string AlbumId="";
foreach (dynamic albumInfo in albums.data)
{
if(albumInfo.name == "Timeline Photos"){AlbumId=albumInfo.id; break;}
}
and the you can use AlbumId to post in the album .
msm2020 solution do the trick but don't forget to add the albums permission: user_photos

Get album id from photo id

When I upload a photo an album is automatically created. There's a way in which I could get the album ID from having the photo ID. Because I have this code:
try {
$response = $facebook->api(
'/me/photos/',
'post',
array(
'message' => 'This is my image caption',
'source' => $source
)
);
$id = $response['id'];
if ($id) {
//obtenemos la url del album
$response = $facebook->api('/'.$id);
unset($_SESSION['uploaded_file']);
header('Location: http://www.facebook.com/'.$id);
exit();
}
} catch ...
And I want to redirect the user to the albums (because I need the user to aprove the photos) instead of the photo. There's a way of doing this without actually asking for all user albums and checking where was the photo uploaded?
If I didn't oversee anything, there is no way to get the album id of the automatically created album.
As a workaround you can upfront create a new album for your application by using the albums connection of the User object. In the response you get the album id which you can use to upload photos specifically to this album and later redirect to it using the link attribute in the Album object.
You can get that info using FQL – first query the photos table for the aid of the album, and then query them album table with that:
SELECT object_id FROM album WHERE aid IN
(SELECT aid FROM photo WHERE object_id = "{your photo’s Graph API id}")
– the object_id will be the Graph API id of the album.

Facebook tagging user on a photo in a Page Gallery via SDK and Graph is possible?

I'm trying to tag a user (having its userid), with a Graph request made to a picture just uploaded to a Page Gallery.
Permissions I use in the app are:
#"read_stream", #"offline_access", #"publish_stream", #"manage_pages",#"photo_upload",#"user_photos" and with a access_token to the session got from page_it?fields=access_token item (that works for picture upload in gallery).
And I use them to upload the photo to a Gallery on a Fan Page successfully.
When I try to tag the user with a graph request in the form:
POST to picture_id/tags with param: "to"->userid
I get only facebookErrDomain error 10000 as if permissions are not right.
From API Documentation seems that only user_photos and publish_stream are required and no mention to page-galleries photo is made.
I'm quite clueless about this issue.
It's possible. You need to collect the page's specific token by placing a call to /me/accounts. And then tag the photo using page's access token. Once you get that, you can tag the photo using it's Graph Object Id and user id whom you are tagging.
if (accessToken) {
var data = {
"access_token": accessToken,
to:userId,
x:x,
y:y
}
FB.api("/" + photoId+"/tags/"+userId , 'post', data, function(response) {
//here is the response
});
}
Hope it helps. The key is the access token that is specific to that page :)