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?
Related
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 am using JavaScript SDK to implement feed functionality. Here is my problem, if a user is logged-in and clicked on share button, Facebook is able to see the post in the timeline, but it is not reflecting in home page.
How can I solve this?
I am using this code -
FB.init({appId: "XXXXXXXXX",show_error:true, status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
FB.ui(obj, callback);
}
You can't decide what appears on the homepage. It depends on the users settings and on how Facebook decides to promote certain types of content.
The homepage is just a condensation of all your friend's/subscription's/page's timelines'. When you share a URL - you share it on your timeline and never share it to the homepage.
This is the expected behavior.
If your application posts something to a users timeline, it is most likely that his/her friends will see it on their homepage but there is currently no way to ensure this. Take for example a situation where one of your users share's a URL but their friends only come into Facebook 2 days later - you can't expect that story to still appear on their homepage after so much time has passed. Like I said - it is likely going to appear on the homepage at some stage - but you have no control over that.
I have a small game in my website, and i want people to post their best time in facebook. To do this, i made an app, and then use the following link:
https://www.facebook.com/dialog/feed?app_id=363262997057304&name=Myname&link=http://www.mywebsite.com&redirect_uri=http://www.mywebsite.com&description=MyDescription
But i dont know how could I do it to populate the message field. what could I do?
The message parameter is deprecated,
also you can use FBJS API to post in a user feed,
function postToFeed() {
var obj = {
method: 'feed',
link: 'https://apps.facebook.com/APP_NAMESPACE/',
picture: 'https://domain.tld/75x75.jpg',
name: 'TITLE',
caption: 'CAPTION',
description: 'My Score: '+score
};
FB.ui(obj);
}
but you have to ask the user for publish_stream permissions first.
You are not supposed to prefill the message field, asper Facebook, unless from a natural flow, such as a user typing in a textbox and sending to the message field on a submit. You should use the description, caption fields for your purpose.
Since you have a game app, all you need to do is to publish their score using the games score API described here: http://developers.facebook.com/docs/score/
From: http://developers.facebook.com/docs/guides/games/
Scores and Achievements
Scores and achievements APIs are built on Open Graph and receive the
same distribution points that all Open Graph stories do - Ticker,
Newsfeed and Timeline. In addition to these scores and achievements
also benefit from built in aggregations and stories that have been
designed by Facebook.
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.
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