How to send multiple link to facebook debugger - facebook

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.

Related

Facebook API post in event - external website

So, I've created a wedding event on my FB account. Now on my website (static) I would like to have a form (maybe embedded or something from FB) that a visitor could leave a message on it for greetings. That message would instantly post on the event I have created.
I hope you understand what I would like to achieve.
Is it now possible to do that? Or Is there an API for this? comment mirroring seems not applicable for events.
If it's not possible to achieve, is there an alternative that is easy to integrate on my site and of course the message will post on FB.
There are tons of APIs for Facebook, all listed on the Facebook developers documentation page: https://developers.facebook.com/docs/
But I think what you're looking for is something like this:
https://developers.facebook.com/docs/javascript/examples
Trigger a Share dialog
The Share Dialog allows someone using a page to post a link to their timeline, or create an Open Graph story. Dialogs displayed using the JavaScript SDK are automatically formatted for the context in which they are loaded - mobile web, or desktop web.
Let's make an API call to publish a message. Add the code into the response function of the FB.login call you added above:
FB.login(function(){
// Note: The call will only work if you accept the permission request
FB.api('/me/feed', 'post', {message: 'Hello, world!'});
}, {scope: 'publish_actions'});
Try the script. A status message will be posted to your timeline: Hello, world!

Facebook OpenGraph - POSTing using the FB.api

This might be a beginners question, but I have to ask it nonetheless since I don't really understand this. I have successfully debugged my page and the user is authenticated to use the app. So the debugger is picking up all my meta og: tags properly. Running the below function allows me to a post a status update to my timeline which is 'A status update'. But that's not what I want, I want the meta og: tags to create a great looking page specific post which Open Graph is all about, but that doesn't happen, it's just a plain old boring status update with a link to my page. Why?
FB.api(
'/me/[my namespace]:button',
'post',
{ message: 'A status update' },
callback function
});
Additionally, what am I actually supposed to put in the third parameter, what is the third parameter for? That is the {message: 'A status update'} parameter.
Finally, is this the way to post to timeline using opengraph and apps? I am not sure as I don't know what that stuff they have when I 'get code' on the developers page is. That curl stuff, what's that for? I can't have that on my page?
But that's not what I want, I want the meta og: tags to create a great looking page specific post which Open Graph is all about, but that doesn't happen, it's just a plain old boring status update with a link to my page. Why?
Because you’re not giving the address of any Open Graph object with your action … there’s no URL anywhere, so where do you think Facebook should pull the OG meta data from …?
Set your action up in a way so that it references some kind of OG object, and then give that object’s URL when you’re publishing the action.
The examples in the Open Graph documentation in the developer section should make pretty clear how it works.
https://developers.facebook.com/docs/opengraph/actions/#create

after user authenticates FB app, how can you get all likes from a specific domain?

I have a website called example.com with several internal pages that are liked.
I created a FB app.
when a user authenticates the FB app, I want to fetch ALL user likes such as: example.com/page1, example.com/page2, etc.
(a single user can have up to 100+ likes on the internal pages of example.com) I essentially want to get all the liked URL's (and associated FB graph ID) the authenticated user has made on my example.com website.
is there a way to do this?
perhaps via a facebook.api call? or perhaps a FQL query? I am open to PHP or JS.
please help! thanks.
...fyi, My initial thought is to for each user, fetch ALL their likes, parse through each one to make sure it came from example.com, and then store those like URL's into a local database. when the user re-visits the site, I will query my database for likes associated with that user. this did not seem the most efficient as it would require storing all likes ever made on my website. any help would be much appreciated.
If you just want to store when a user likes a page on your website why not make use of the edge.create and edge.remove events the Facebook JS SDK provides? Example:
FB.Event.subscribe('edge.create', function(targetUrl, elm) {
// Make a request to server to save 'Like' information
});
FB.Event.subscribe('edge.remove', function(targetUrl, elm) {
// Make a request to server to remove 'Like' information
});
I see in the attributes of the like plugin, that the ref attribute might be what you could use to determine where a like came from. Of course your href attribute would need to be the same on all locations of the like button.
Or, you can register your site with facebook insights and track it there. See https://www.facebook.com/insights/
The User API reference is here: https://developers.facebook.com/docs/reference/api/user/
Here's how you get all the likes via the JS API (unless they're more than one page, they you get a subset of the likes):
FB.api('/me/likes', function(response) {
console.log(response);
});
You need to be logged in, and you need the user_likes permission.

How to auto like facebook page from other site?

On the facebook page,we can click the like button to like the page.
How can we use any api or plugin to realize from other site?
You can not automatically like an object for a user nor can you present like via the APIs. This prevents anyone "secretly" having users like pages / objects.
The solution is to embed a like button to your page and give users a clear reason to use it [sell the benefit of liking your page]. You can run a separate version for individual pages, objects or just an aggregate button for all of your site via the data-href element.
http://developers.facebook.com/docs/reference/plugins/like/
You can check if a user has liked your page using:
FB.api('/me/likes', function(response) {
console.log(response);
});
Loop through the response and look for your page ID.
The open-graph api has now been updated to support creating (and deleting) likes.
See here:
https://developers.facebook.com/docs/opengraph/actions/builtin/likes/

'Like' a page using Facebook Graph API

Using the Graph API I'd like to be able to have an authorized user "like" a page.
I tried posting the following
https://graph.facebook.com/${PAGE_ID}/likes?access_token=${ACCESS_TOKEN}
And I get an HTTP error 500 accompanied by "Invalid post_id parameter" in the JSON response body. Looks like the /likes resource is suited to liking a wall post and not a page. How do I get this to work with a page?
Facebook has announced support for liking URL's outside of Facebook by using the official built-in Like action. You need to have publish_actions permissions. The graph url for this is:
https://graph.facebook.com/[User FB ID]/og.likes?object=OG_OBJECT_URL&access_token=USER_ACCESS_TOKEN
However, you cannot use this to like a page on Facebook currently, as the documentation states:
For Facebook Pages or websites that do not integrate with Facebook
Authentication, developers should continue to use the Like button
social plugin.
Update June 2016
It's still not possible to like a page using Facebook API, as stated in the /{user_id}/likes documentation page about Creating/Updating/Deleting:
You can't perform this operation on this endpoint.
In previous versions the message was clearer (see the quote below), but the result is the same: it's not possible.
May 2014
The /{user-id}/likes documentation page States about Publishing Likes of Facebook Pages:
You can't publish using this edge, as it is not possible to like a Facebook Page via any API. You should use the Like Button if you want people to be able to like a page in your app.
This is the most obvious and clear statement that has been able to give me an answer to the question.
if your app is an open graph app, now you can like using the api, and no need for the button anymore.
https://developers.facebook.com/docs/opengraph/actions/builtin/likes/
If you want this functionality in a page tab or canvas page within facebook (say to allow for liking the page from within a likegated page), a work around you can involves what Tom Wells suggested in his reply to Luke. You first embed the iframe version of their like button on your page, and then simply listen for the edge.create event in your JS like so:
FB.Event.subscribe('edge.create',
function(response) {
alert('You liked the URL: ' + response);
// ...
}
);
In the callback, you can deal with with what happens when the user has liked the page, say like navigating away from the like-gate page, or showing liked-only content.
When the user clicks the iFrame like button, your JS code should receive the edge.create event assuming the iFrame was configured to point to the url of the page in question.
I believe this is not allowed except for specific partner sites, like yelp. The reason is security, you would be able to put some javascript on a page and have everyone that visits that page "Like"ing it without their knowledge.
See How do I "Like" a URL? on the Facebook Platform Developer Forum
You can like an object with its object id using Facebook api using the following piece of code
[FBRequestConnection startForPostWithGraphPath:[NSString stringWithFormat:#"/%#/likes",{object_id}] graphObject:nil completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
//do you customisation post like here
}];