The posts fo Feed method in FB.ui are not visible in Facebook timeline - facebook

I created an Application in facebook and used in my website.
In my page I am using this function to share a photo.
function postToFacebook(url, img) {
FB.ui({
method: 'feed',
link: url,
picture: img,
name: "Sample name",
description: 'sample desc'
}, function (response) {
console.log(response);
});
}
This function is working and sending a ShareLink on my Time line. But nobody can see my post. I just can see the post on my TimeLine !!!
What it is the problem?

I found out the problem myself.
it is because of the Status of Facebook Application.
Do this setting to fix the problem:
Go to Facebook Developer => You Application => Status & Review => set this option to YES:
"Do you want to make this app and all its live features available to the general public?"

Related

How to share individual images in facebook

I would like to enable users to share a certain feed with dynamically generated pictures. This means that the picture url is always a new one.
However, it seems that the picture Facebook is using is not that from the URL but always (an old) one from the cache.
The URL is something like http://www.domain.com/facebook/unique-picture.png
How is it possible to turn off the caching?
function shareMessage(link) {
alert(link);
FB.ui(
{
method: 'feed',
name: link,
link: 'link',
picture: link,
caption: link,
description: "description",
message: ''
});
}

Fb.UI dont work so fine

https://developers.facebook.com/docs/javascript/reference/FB.ui
With the new update of Facebook API, I've been trying show a dialog for share in timeline, but don't only recognize me the href..
What can I do?
Code:
FB.ui({
name: 'Mejores Huecas',
link: 'www.lasmejoreshuecas.com',
from: '1469541393326876',
caption: 'Las mejores huecas!',
method: 'share',
href: 'https://apps.facebook.com/mejoreshuecas/?fb_source=search&ref=ts&fref=ts',
},
function(response) {
if (response && !response.error_code) {
//alert('Posting completed.');
}
else {
//alert('Error while posting.');
}
}
);
That´s intentional, the Share Dialog reads the data from the Open Graph Tags of the URL and it only takes the href as parameter, as you can see in the docs.
If you want to share custom data, you need to create a separate URL with separate Open Graph tags. After all you share a Link, and the message must be user generated anyway, so you don´t really need additional info - i guess that is why Facebook deprecated the old Feed Dialog.

How can I redirect to my app page after accepted a app request sent from our app?

I have a issue for facebook apprequests (oauth2, graph)
I sent a app request to my friend B.
B logged into facebook and found our request in the app list.
B clicked the accept button
B redirected to the facebook canvas page. I want to rediect to our app, not facebook's canvas, is this doable?
thanks
you can put a url in the data param
see here http://developers.facebook.com/docs/reference/dialogs/requests/ under properties at bottom.
data Optional, additional data you may pass for tracking. This will
be stored as part of the request objects created.
This will get passed back to you and you can use javascript to location.href to the url in the data.
----------Here is a sample i have used in the past
var thisimg = 'AN_IMG';
var thisurl = 'A_URL';
window.sendrequest = function(){
FB.ui({ method: 'apprequests',
title: 'A request.',
message: 'Rate Me! Request from: ' +thisname+' ',
data: ''+thisimg+' '+thisurl+' ',
filters: ['all'],
});
}
---------- Sample from Facebook with data param added.
var thisimg = 'AN_IMG';
var thisurl = 'A_URL';
function sendRequestToManyRecipients() {
FB.ui({method: 'apprequests',
message: 'My Great Request',
data: ''+thisimg+' '+thisurl+' ',
}, requestCallback);
}
function requestCallback(response) {
// Handle callback here
}
upon callback you can do a window.top.location.href=''; with the url you passed in data.
NOTE: The default redirect for a request is the canvas, this cannot be changed. After user lands on your canvas you will read the data param from the request and redirect them to your external app.
"i do not see any other way to do this, since requests2.0 does not include option for a redirect uri."
As you have already included Facebook javascript SDK in your App and you have writen this code for inviting friend for your App in a script
FB.ui({ method: 'apprequests', redirect_uri: 'APP URL',
message: 'My Message' });
This will redirect to App URL without redirecting to Facebook canvas URL.So this will not work even if you use data parameter such as
FB.ui({ method: 'apprequests', data: 'APP URL',
message: 'My Message' });
Write this code at your App landing page i.e. in index.php
$requestid=$_GET[request_ids];
if(!empty($requestid)) {
echo "<script> window.top.location.href='APP URL'; </script>";
}
This is an old question, but now there is a simpler solution.
In the Facebook app settings under "Facebook Canvas" there is a field titled "Mobile Site URL". When a user tries to open your canvas app from a mobile device (s)he will be redirected to that URL.
That URL should point to a page from which you should redirect to the App Store or Play Store (or coming soon page) based on the browser user agent.

FB.ui feed post dialog changes

When a user posts a comment on one of our sites, we give them the option to send the comment to their facebook wall. i.e. the following code:
FB.ui({
method: "stream.publish",
attachment: {
"name": "article title",
"href": document.location.href,
"description": "an excerpt from the article"
}
message: userComment, // The comment that the user entered on our site
user_prompt_message: shareText // "What do you think?" or similar, configurable
}, function(response){
if(response && response.post_id){
// success!
}
else{
// failed!
}
});
This popped up a dialog with the "your comment here" input pre-filled with the same comment the user posted on our site. Was totally fine via the Facebook Platform Policies, even officially encouraged at the time we initially put it into place.
But evidently they deprecated the message parameter on July 12th. So now you get a big "share" box and the content you actually want to share (the user's comment) isn't included anywhere. So, we're looking for another way to post the user's comment.
So, the latest documentation on stream.publish still says we can pass the message parameter directly via the API call, i.e.
https://api.facebook.com/method/stream.publish?callback=derp&message=EABOD+Facebook&access_token=MY_ACCESS_TOKEN&format=json
I tested it and it works, but I'm wondering if it will still work going forward, or if they just haven't shut it down yet?
If it'll replaced, i will be the feed method, which is very similar to streem method.
FB.ui(
{
method: 'feed',
link: 'http://myapp.com/myitem',
display: 'iframe',
picture: 'http://myapp.com/mylogo.jpg',
message: 'my message',
name: 'click to see item',
caption: 'title'
})
we will see next major version and see!

Facebook API: Suggest page to friends and view which are were selected

I am developing an application which is based on user challenges. The app also requires a Facebook account to play.
I want a user to be able to select a bunch of friends he wants to challenge and send them an "invitation". But besides this, I need to find which friends did the user invite in order to save them to my database and "prepare" the challenge.
I managed to do the select-friends-dialog using this, but have no idea how to retrieve the selected users. Also, does this work on non-canvas Facebook applications? As I read that page, I am not sure whether it will work for my non-canvas application.
Here is my select-friends-dialog code:
function challengeFriends(){
FB.ui({
method: 'apprequests',
message: 'message",
title: 'title'
});
}
Any help is highly appreciated! Thank you.
I've written a tutorial that covers what you are asking for and other aspects of the Request dialog: How To: Send An Application Request Using The Facebook Graph API
The idea is to capture the request ids from the callback and save them in your DB, and within the request itself you can find the invitee id (friend id):
FB.ui({
method: 'apprequests',
message: 'Check out this application!',
title: 'Send your friends an application request',
},
function (response) {
if (response && response.request_ids) {
var requests = response.request_ids.join(',');
$.post('handle_requests.php',{uid: <?php echo $uid; ?>, request_ids: requests},function(resp) {
});
} else {
alert('canceled');
}
});