Facebook Graph API - Javascript SDK - facebook

How can I post to a user's wall using Javascript SDK?

Facebook strongly advises against directly posting to user's feed without direct consent of each specific post, you should really try using the javascript SDK's FB.ui functionality:
function PostToWall(msg) {
FB.ui(
{
method: 'feed',
name: 'I'm using this great app and it says that '"+msg"'",
link: 'http://apps.facebook.com/link-to-app,
picture: 'http://yourdomain.com/images/facebook-logo.png',
caption: 'Small caption that will appear in grey'
}
);
}
Read more about it here

Related

Facebook Open Graph with JavaScript SDK

Are Open Graph tags necessary when using the JavaScript SDK UI API, provided by Facebook? My understanding is that the FB crawler reads the open graph tags to use as content for the post being shared. However, the SDK provides options where you can specify these. How do these work with each other?
Facebook will use the following (from the JS SDK) over the OG tags:
FB.ui({
method: 'share',
display: 'popup',
href: 'https://url.com',
quote: 'Im a quote!'
});

Using the FB API, can you share a link, but serve an image that is not on the page

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

Share a Spotify track using the Facebook API

I've been using the Facebook API for quite a long time, I've managed to post to feed pictures, videos, and links, but my client wants to post a Spotify track through a Facebook App.
For instance, to share this track: http://open.spotify.com/track/5yEPxDjbbzUzyauGtnmVEC
When I copy this into Facebook's post input, it loads the correct song name and cover. However, if I use the FB.ui API call, it just doesn't share anything around.
var data = {
method: 'feed',
link: MY_FB_TAB,
name: name,
caption: caption,
description: description,
message: '',
picture: 'https://embed.spotify.com/oembed/?url=spotify:track:5yEPxDjbbzUzyauGtnmVEC',
source: 'http://open.spotify.com/track/5yEPxDjbbzUzyauGtnmVEC'
}
FB.ui(data);
Isn't just a way to share a track using the FB.ui dialogs?

Facebook: Can mobile feed dialogs be customized?

I want to create a post to a user's wall via my facebook connect mobile app. I looked on the FB developer's website and only found this to post through mobile:
http://www.facebook.com/dialog/feed?
client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&display=touch
along with this statement The current version of the JavaScript SDK does not yet supporting automatically selecting the correct dialog for the user's device. We expect to add this capability shortly.
Has this been fixed yet? I have been trying to workaround using the normal method:
//Post on user's wall
FB.ui(
{
method: 'feed',
name: 'MyApp',
link: 'myURL',
picture: 'http://fbrell.com/f8.jpg',
caption: caption,
description: message,
message: ''
},
function (response) {
});
But it is slow and doesn't work the way I want it to.
Suggestions?
As of now no the cannot. You can still do auto publish posts though.

Post on Facebook Wall

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.