简体   繁体   中英

Facebook Comments on your website via Graph API instead of Comments plugin?

Facebook offers the Comments Plugin for adding comments to any website:

https://developers.facebook.com/docs/reference/plugins/comments/

Is it possible to GET and POST comments to your website via the Graph API?

My "URL to comment on" is http://www.examplesite.com/test/ . If I use the above comments plugin to add a comment to my site, I can access all the comments at the following URL:

https://graph.facebook.com/comments/?id=http://www.examplesite.com/test

Now, is there a way to POST and GET comments to this via the Graph API? I assume my "post id" is http://www.examplesite.com/test . I'm trying to use the PHP SDK like so:

$params = array( 'message' => 'Hello World!!' );
$facebook->api("http://www.examplesite.com/test/comments", "POST", $params);

Also tried to fetch comments as well:

$comments = $facebook->api("http://www.examplesite.com/test/comments", "GET");

No dice with either of those. Can't post comments or fetch comments.

Am I doing something wrong? Or is it not possible to add comments to your site via the API?

Dunno about the comment post. but you can get the comments as an assoc array via the API as follows:

    $url = 'http://test.com';
    $arr = $this->facebook->api('comments/?ids='.$url); 

    echo("<pre>");
    print_r($arr[$url]['comments']['data']); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM