0

This is confusing. So just to clarify:

REQ #1: To fetch basic stats for a URL, you send GET request to:

http://graph.facebook.com/?ids=http://some.com

(alternatively, FQL can be used to fetch stats for a URL, but that doesn't return the OpenGraph Object)

REQ #2: To fetch comments for a URL, you do a GET:

http://graph.facebook.com/comments/?ids=http://some.com

REQ #3: To fetch likes for a URL, you GET:

http://graph.facebook.com/likes/?ids=http://some.com

But how do you comment on / like a URL programmatically?

I guess, likes can be created using Open Graph API, right?

https://graph.facebook.com/me/og.likes?object=1234

where 1234 is the OpenGraph Object ID of an article (as returned by REQ #1). But this requires an approval process, the like action has to be approved by Facebook.

Is there a better way to do this? Can I use for example the Graph API for all these things?

My goal:

Currently I'm using the Facebook like button and comments plugin to create likes and comments. But these use the JS SDK, which is huge, and they generate a lot of external requests. I wanna get rid of them and just send an AJAX request to my server, which would then asynchronously talk to Facebook, and it would post the Like / Comment.

Is this possible?

Thanks in advance!

user2297996
  • 1,382
  • 3
  • 18
  • 28

3 Answers3

0

I read through the Facebook docs briefly and I don't believe you can do this other than the way you indicated with authenticating.

You should also take a look at this thread: 'Like' a page using Facebook Graph API

Community
  • 1
  • 1
Matthew
  • 44
  • 2
  • Cool Thx. from Facebook docs: "The viewer of the in-app content is a Facebook user who has Facebook-authed and granted the app publish_actions permission" So "Facebook-authed" means the users have to be logged in both my site and Facebook, right? – user2297996 Aug 30 '14 at 11:05
  • And of course the users would need authorize my app. But once they did that, would the custom like button work if they are not logged in my site, just Facebook? – user2297996 Aug 30 '14 at 11:23
0

You would need to authorize every single user before he would be able to like something, and you would need to go through a review process on Facebook. And i am pretty sure you would not get the required permissions approved just because you want to get rid of the JavaScript SDK overhead, to be honest.

The Social Plugins are asynchronously, so the overhead for downloading the SDK is irrelevant as it happens in the background and it is non-blocking.

andyrandy
  • 72,880
  • 8
  • 113
  • 130
0

I have an idea, to do this. You can use long term access token, Once you login you receive short term token. After receiving short term token you need to request your long term access token. Save that token in DB or file.

Then you can use Graph Api, to make requests. This will eliminate the need for access requirement every time you request api.

Just use access token you saved before.

Refer this documentation from Facebook for further clarity.

https://developers.facebook.com/docs/facebook-login/access-tokens

Happy Coding!

Atul Jindal

Atul Jindal
  • 946
  • 8
  • 8