I post an action to a Facebook news feed from a website. I am getting a look that is not quite what I want to have:
I want it to be larger, like this one:
I am using JS SDK for posting, code comes from App, for testing-only in a dev-env it is currently following: (assuming user is authorized with correct permissions)
FB.api(
'me/aeegens:win',
'post',
{
thropy: "http://samples.ogp.me/444294502324595"
},
function(response) {
console.log(response);
}
};
I tried to look for solution in Facebook API documentation, but could not find it.
Answer is simple, one needs to have a bigger image.
Related
I have a website with some dynamic urls (for example a page who show event details thanks to event id in get variable), but during the share with facebook, at the first attempt the thumbnail image doesn't appear due the page isn't already fetched by facebook.
Then I must go to the debugger https://developers.facebook.com/tools/debug/og/object/ and submit every pages to get a valid thumbnail to the users.
There's a script or a way to send multiple links to this debugger, or there's another way to achieve the indexing of new pages by facebook?
You can refresh the Open Graph tags with a POST request to the Graph API, i think it´s not in the Facebook docs (at least i could not find it) - but it definitely works:
$.post('https://graph.facebook.com', {
id: 'http://www.yourdomain.com/somefile.html',
scrape: true
}, function(response) {
console.log(response);
});
Just an example with jQuery, of course you can just use CURL on the server too.
I can post a photo IF I had the time to get an app approved. I can share a link that pulls in a photo from THAT page. The goal is to post a link that goes to X, but the image is hosted somewhere else.
Is this possible?
Yes, it's possible by using the JavaScript SDK and the Share Dialog. For example, I can do the following, which shares a link but with a custom image, name and caption. It basically overwrites all the OG data on my page.
function fb_share() {
FB.ui( {
method: 'feed',
name: "Facebook API: Tracking Shares using the JavaScript SDK",
link: "https://www.webniraj.com/2013/05/11/facebook-api-tracking-shares-using-the-javascript-sdk/",
picture: "https://stackexchange.com/users/flair/557969.png",
caption: "Tracking Facebook Shares on your website or application is a useful way of seeing how popular your articles are with your readers. In order to tracking Shares, you must used the Facebook JavaScript SDK."
}, function( response ) {
// do nothing
} );
}
$(document).ready(function(){
$('button.share-btn').on( 'click', fb_share );
});
You can do the same thing in PHP if you have the publish_actions permission approved by Facebook. Both would produce the following result:
Source
I'm trying to pull a list of my friends in Facebook's OG api v2. If I use the explorer here:
https://developers.facebook.com/tools/explorer?method=GET&path=me%2Ffriends&version=v2.0
I can get my friends, but if I program the app and make a json call:
function getUserFriends(){
FB.api('/me/friends', function(response) {
console.log(response);
});
}
The friends array response is an empty object.
I'm using the facebook login button:
<fb:login-button scope="public_profile,email,user_about_me,user_birthday,user_education_history,user_hometown,user_location,user_relationships,user_relationship_details,user_photos,user_friends,read_friendlists" onlogin="checkLoginState();">
</fb:login-button>
and I can access a lot of other data about myself, but not friends. Any idea what I'm missing?
Facebook changed a lot of things recently, for privacy reasons you can only get the friends who are also using the App now. See here:
https://developers.facebook.com/docs/apps/changelog
https://developers.facebook.com/docs/apps/upgrading/
Also see here: Friendslist doesn't work anymore after the powerful access_token
I have a website where there is comments systems. I want to add a comment to facebook while adding a comment to my website.
If it is not possible to add to Facebook while adding to my site is it possible to show share to facebook button with each comments so that clicking on it will share that comment on facebook. May be possible with fb.in?
Not 100% sure, but it sounds like you have your own comment system on your web site and that you'd like to auto-publish to FB the comment that someone makes on your own site.
You'd need to implement the Facebook SDK on your web site:
Have your user authorize your site using 'FB.login' with 'publish_stream' permission (see docs).
In your comment system code, after your user has entered in their comment, you can make a separate call to the Graph API to publish to the user's feed. For example, if using the Facebook Javascript SDK:
Following is the code:
var body = myJustEnteredComment;
FB.api('/me/feed', 'post', { message: body }, function(response)
{
if (!response || response.error)
{
alert('Error!');
}
});
It seems that the way of posting to your wall or friends wall has change. Can anyone understand how you can do it?
Changed since when? Facebook seems to change things every quarter. Some of the latest ways are using the Graph API:
http://developers.facebook.com/docs/reference/dialogs/feed/
or using the javascript SDK and the FB.ui method:
http://developers.facebook.com/docs/reference/javascript/FB.ui/
FB.ui({
method:'feed', to:1234567890123, name:'Check this out', link:'http://link.com',
description:'very funny, a must see'
}, function(response) {
//log response
}
)
You just go to your friend's page and use the normal 'Share / Write something' functionality - it will appear on your friend's wall.