Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'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?

like image 483
Tom Wells Avatar asked Jun 17 '10 11:06

Tom Wells


People also ask

What data can I get from Facebook Graph API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.

How do I get Facebook Page Insights on graph API?

You can access Page Insights by typing /insights after the name of your page in the URL field. This command will retrieve all of the Insights associated with your Page. Type "/insights" after your company name. Click the Submit button.

Is Facebook Graph API deprecated?

Applies to all versions. Facebook Analytics will no longer be available after June 30, 2021. Additionally, we are deprecating the App Dashboard Plugin for Marketing API. For more information visit the Business Help Center.


1 Answers

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.

like image 193
bkaid Avatar answered Sep 24 '22 23:09

bkaid