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.
Related
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?"
I'm having problems with the way the custom story that I have is displayed on Facebook.
It's working fine but instead of publishing on the wall of the user, it appears in the Recent Activity section.
The steps I follow until now:
create the custom action 'Want'
set the 'Explicitly Shared' option on
run this code:
FB.api(
'me/mynamespace:want',
'post',
{
article: "https://developers.facebook.com/docs?locale=es_LA"
},
function (response) {
console.log(response);
}
);
Can anyone help me?
If you need more info let me know. Thanks
You don't set explicitly shared to on. You need to do that in the API call.
I am following this thread Is it possible to add a link to download a file that can only be downloaded by sharing it on Facebook? to detect if user share my given link or not, If user share then allow him to access the next level.
This is how i am doing:
FB.ui({
display: 'popup',
method: 'share',
href: 'url-here',
} , function(response){
console.log(response.e2e)
if (response && response) {
$.ajax({
url: ajaxurl,
type: 'post',
data: {action: 'unlock_om_gmap'},
success: function(res) {
}
});
}
});
But everytime its returning Object { e2e="{"submit_0":1406412308276}"} not any post id. Is there anyone familiar with this issue? How do i check if user shared my link or not?
As I mentioned in the comments, as per the Facebook docs on this topic, you'll need to check for an object_id property in the response data to determine if an Open Graph story was shared, but this is only available if the user is logged into your app using Facebook and has granted publish_actions
I've put together a script, with the help of another SA post, but the issue I'm having is it's always returning error. When logging the error with console log it contains no properties so I can't determine why I am getting the error.
$(".add-image").click(function() {
FB.login(function(response) {
if (response.authResponse) {
var imgURL="http://farm4.staticflickr.com/3332/3451193407_b7f047f4b4_o.jpg";
FB.api('/album_id/photos', 'post', {
message:'Test',
url:imgURL
}, function(response){
if (!response || response.error) {
console.log(response);
} else {
alert('Post ID: ' + response.id);
}
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'publish_stream'});
});
I've created the app. Added the API ID when including the Javascript.
When running I get a pop up asking me to log in, and it seems to log me in without problems. But it returns an error when checking for a response or response.error.
Any advice.
Not sure if this is still a problem for you, but I've been looking into the same thing recently and I believe that, for this type of upload, FB basically requires source to be the image data itself, not a URL to the image. (See the create photos section on https://developers.facebook.com/docs/reference/api/album/ - it indicates that the source paramater must be multipart/form-data.)
So you have a few workarounds:
1) You may be able to do it from JS if you can create a custom Open Graph Object. I haven't tried this yet, but https://developers.facebook.com/docs/opengraph/usergeneratedphotos/ looks like it expects a URL rather than the post data itself.
2) If the image is originating on the user's computer, you can create an HTML form that submits to FB and have the image go directly from the user to FB without ever hitting your server. This blog post shows an example of that: https://developers.facebook.com/blog/post/498/
3) If the image is originating in your system, you can do a POST from your server to FB that mimics the above form. If it's somewhere else online (such as Flickr), you can download it to your system first and then POST it to FB. You'll have to include an access_token in the request. I don't know what language / framework you're using on your server, but there's probably a library to make creating POST requests easier.
I suppose the answer is pretty simple, but i cant find conclusive answer either way.
Is it possible to use facebook to log in a user, fetch their friends, allow them to select them and then post to their profiles in turn, even if that means firing up a custom modal with html to select from the list of users friends before passing the IDs on to the publishStream function in a loop.
Any response would be dandy. Thanks guys and gals.
If you post to the logged-in user's stream, you have no control over which friends see it in their own streams.
Alternatively, you can send facebook notifications to friends that were selected, subject to the daily notification limit imposed on your app by facebook. Be aware that facebook is phasing out noficiations.
You can do exactly what you said. Just get the list of user IDs before hand using your custom dialog you mentioned. Then call the FB.ui function repeatedly, populating the "to" parameter with each friend ID.
FB.ui(
{
method: 'feed',
to: #,
name: 'name of post',
link: 'http://link.com',
picture: 'http://link.com/image.jpg',
description: 'descriptive text',
},
function(response) {
if (response && response.post_id) {
alert('Post was published.'+response);
} else {
alert('Post was not published.'+response);
}
}
);