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

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

Related

Facebook sdk How can I get url from photo id

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

Upload photo to facebook with tags

I'm creating a Facebook Flash app and I'm having trouble uploading a photo to Facebook with myself or friends tagged. I am stuck at this for a whole time now and couldn't find the solution
First of all here are the permissons I want the app to have.
ExternalInterface.call("redirect","appId","user_birthday,read_stream,publish_stream,user_photos,friends_photos","http://apps.facebook.com/appName");
Here is what I do to upload the photo to Facebook without tags (this works):
var params:Object = {name: 'My Card', image:card, message: 'Greetings from Barcelona' , fileName:'Card'};
Facebook.api('me/photos', onSaveToPhotoAlbumComplete, params);
But when I want to add tags of friends or myself it doesn't work, Here is what I did (In this case I only want to tag myself in the picture):
var params:Object = {name: 'Rosada Face-It', image:card, message:message, fileName:'Face It!', tags:[{"id":myId,"x":50,"y":50}]};
Facebook.api('me/photos', onSaveToPhotoAlbumComplete, params);
I also tried it with quotes and "tag_uid" instead of "id" but that is not the problem I think:
tags:'[{"tag_uid":"'+ editorModel.tag1 +'","x":"50","y":"50"}]'
If somebody could help?
Looking at the API I think a seperate call may be needed to add tags
http://developers.facebook.com/docs/reference/api/photo/
I think to create a tag you need to have the PHOTO_ID and then do a POST to PHOTO_ID/tags
var params:Object = {{"to":myId, "x":50, "y":50}]};
Facebook.api(photoId +"/tags", onPhotoTagged, params);

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 :)

How to get facebook profile picture with 'F'-logo?

I use Graph API and I need to get users' profiles pictures by their UIDs.
It's easy to do: http://graph.facebook.com/[Facebook UID]/picture
I remember, some time ago, there was a litte Facebook Logo (litter 'f'-char) on these profile pictures. But now, I get only profile pictures without this logo.
How can I get images with this 'f'-logo?
Facebook doesn't store images with the 'f' on, so it's a little hacky to get at them.
I've found that this works:
You'll need the final image url, after graph.facebook.com/[id]/picture redirects.
http://external.ak.fbcdn.net/safe_image.php?&url=[imageurl]&logo
eg. me
I think it's not possible using the graph api.
It was possible using FQL (dont know if it is still working):
SELECT pic_with_logo FROM user WHERE uid = "..."
or use xfbml with <fb:profile-pic facebook-logo="true">
With jQuery and JS API you can make an FQL call:
FB.api({ method: 'fql.query', query: 'SELECT uid, pic_with_logo FROM user WHERE uid = me()' }, function(response) {
var user = response[0];
$('#container').append('<img src="'+user.pic_with_logo+'"/><br>');
});
also you can try:
pic_small_with_logo, pic_big_with_logo, pic_square_with_logo and the pic_with_logo i use in example.
here is the user table:
https://developers.facebook.com/docs/reference/fql/user/
Based on Tom's answer, Here is php example to get user's
$_json = json_decode(file_get_contents('http://graph.facebook.com/[FACEBOOK_UID]?fields=picture'));
if (isset($_json->picture)) {
header("Location: http://external.ak.fbcdn.net/safe_image.php?&url=" . $_json->picture . "&logo");
exit;
}
Here is what we do:
Query picture url via opengraph
Get the picture url from json object
redirect the page to facebook image handler with addition &logo to url