How to Get user profile picture URL by Facebook Id? - facebook

After Recent Facebook changes
http://graph.facebook.com/" + facebookId + "/picture?type=square
is downloading image instead of displaying image.
https://graph.facebook.com/118844755560695/picture?type=large

Do an API request with one of the SDKs and you will get the following JSON:
{
"data": {
"is_silhouette": true,
"url": "https://static.xx.fbcdn.net/rsrc.php/v3/yL/r/HsTZSDw4avx.gif"
}
}
The url is what you can use for display.

Related

filepicker.io generate title for uploaded photos

we have developed an application with which we can generate a new album and than upload many photos into it. The generated album is then shown at the page profile
filepicker.pickMultiple(
{
mimetype: 'image/*',
maxFiles: 3
},
function(Blobs){
console.log(JSON.stringify(Blobs));
},
function(error){
// console.log(JSON.stringify(error)); - print errors to console
}
);
We are using this, but there is no options to mention the "Title" of the album or photos.
Can anyone help me on this?.

Canvas -> Base64 post to Facebook

I have implemented a pure javascript function for sharing canvas content to an user's facebook wall. The implementation works, but the problem is:
Facebook does not approve the app, stating after review:
"publish_actions on Web - Your app's users must enter all content
in the user message field. Don't auto-populate the message field with
any content, including links and hashtags, even if you allow users to
edit the content before sharing. Watch this informational video for
more information, and see Platform Policy 2.3"
Afaik, there is no way to pass a base64 object through the FB.ui feed share dialogue with client side javascript only.
Question: Any workarounds or other ways go get a client side only canvas -> facebook share implementation that is passed by the Facebook app approval process?
The current implementation is as follows:
document.getElementById('facebook-link').onclick=function(){
FB.login(function (response) {
if (response.authResponse) {
window.authToken = response.authResponse.accessToken;
PostImageToFacebook(window.authToken);
} else {
}
}, {
scope: 'publish_actions'
});
};
function PostImageToFacebook(authToken) {
var imageData = canvas.toDataURL("image/png");
try {
blob = dataURItoBlob(imageData);
}
catch (e)
{
console.log(e);
}
var fd = new FormData();
fd.append("access_token", authToken);
fd.append("source", blob);
try {
$.ajax({
url: "https://graph.facebook.com/me/photos?access_token=" + authToken,
type: "POST",
data: fd,
processData: false,
contentType: false,
cache: false,
success: function (data) {
console.log("success " + data);
},
error: function (shr, status, data) {
alert.log("error " + data + " Status " + shr.status);
},
complete: function () {
console.log("Posted to facebook");
$('#facebook-link').text('Ferdig delt :)').removeClass( "inProgress" );
}
});
} catch (e) {
console.log(e);
}
}
The implementation does not append any text, making me wonder why it does not comply with the Facebook Platform Policy section 2.3.
I had the same problem in an application. Although we have chosen to use the database, I believe it has a solution to your problem.
Really has no way to share a Base64 code by FB.Ui
But as the policies of Facebook, you are not required to use it.
You can create a custom dialog window for the user to view the image that is being posted and enter/confirm the message, and posting after this action.
As the explanatory video from Facebook, the message posted by the user can not be changed, then it should be approved without problems.

Fb.ui method feed not working. Loading gif appears but no error message or anything

So I've been trying to implement a Fb method feed so that people can share songs from my website. But it doesn't work.
It pops up a loading gif in the dialogue and thats it. No error nothing. I've wasted a lot of time trying to figure this out but haven't been able to.
Here's the code,
share_obj = { method: 'feed',
link: "", redirect_uri: "",
picture: ",
name: "",
caption:"" ,
description: ""
}; FB.ui({method: "permissions.request", "perms": 'publish_stream'},
callBack);
function callBack(response) { if(response["perms"]=="publish_stream") { var obj = share_obj; FB.ui(obj,callback_share); } } function callback_share(response) { }
Does it have something to do with Facebook app migrations or app permissions?
So turns out, there s no need to ask for user permissions when invoking the Fb.ui method.
Permissions are only required when you intend to publish stories via the graph API.

Facebook LIKE AppId or PageId

I am having an issue logging a "LIKE" for an application page. It seems that the like is not being inserted into the page_fan table. My concern is that I may be trying to LIKE the application page and not the actual page that contains the application as a tab. I have already written the LIKE code and the like does post to my wall etc. but when I perform the me() query against the page_fan table it does note return my uid.
I have tried the LIKE both within my custom page was well as the global LIKE above all canvas pages on FB page.
My question is: Should my code logic LIKE the ApplicationId(Canvas/iframe) or the PageId in which the Tab exists? Or I am totally off base with my logic.
Here is what I have developed and what I have found.
I have created applications that are accessible on the left hand side of a facebook page (tabs). These are canvas or iframe applications that generate a unique AppId when a new application is created.
For example, I am currently adding the AppId of a canvas page as an OG tag in same canvas iframe page.
I then access the following URL and select the page from an existing list that this tab should appear:
www.facebook.com/dialog/pagetab?app_id=111111111111111&display=popup&next=http://facebook.myapp.com/canvaspage.html
I wrote the following code to determine the page_id (for example this returned:222222222222222)
//App PageId
var url = 'https://graph.facebook.com/fql?q=SELECT url, id, type, site FROM object_url WHERE url="'+appURL+'"';
$.getJSON(url, function(data) {
$.each(data['data'], function(index, appPageId) {
if (appPageId) {
var appPageId = appPageId['id'];
}
});
});
<!-- Open Graph for the "PAGE" PagId that has a relationship to AppId (id:) below / I have found that this will include a likes variable if GT 0 -->
graph.facebook.com/222222222222222
{
"id": "222222222222222",
"name": "TEST APPLICATION",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-ash2/373257_225429330866626_1701496970_s.jpg",
"link": "http://apps.facebook.com/test-app/",
"app_id": 111111111111111, // Below ID - also the AppId
"category": "Website",
"description": "Test App Description",
"can_post": true
}
<!-- Open Graph for "APPLICATION" AppId --->
graph.facebook.com/111111111111111
{
"id": "111111111111111",
"name": "TEST APPLICATION",
"category": "Lifestyle",
"subcategory": "Food & Drink",
"link": "http://www.facebook.com/apps/application.php?id=111111111111111",
"canvas_name": "test-app",
"namespace": "test-app",
"icon_url": "http://static.ak.fbcdn.net/rsrc.php/v1/yT/r/4QVMqOjUhcd.gif",
"logo_url": "http://static.ak.fbcdn.net/rsrc.php/v1/yq/r/IobSBNz4FuT.gif",
"weekly_active_users": "2",
"monthly_active_users": "2"
}
Thanks in advance for your assistance.
You will want to like the Facebook page, not the app ID. Remember a facebook page can have many App Id's in it (what facebook calls Page tabs).

How to Tag photo in facebook with certain position

this is my app image...this uploads friends photo but,.,,tag is not inrandom position..please help me to tag friends image correctly
http://shapper.co.tv/1/hiii.jpg
Once you have the photo's Graph ID, you can tag your friends by passing the co-ordinate, like the following Graph API call with JS-SDK
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.