Search code examples
phpfacebookfacebook-graph-apifacebook-comments

Facebook Graph API PHP to make a comment to a post on a page as page


I'm using below code to post to my facebook page as page

$post_id = $facebook->api("/$page_id/feed","post",$args);

I want to make a comment to the post I created. I don't know how to do that exactly. But based on some research, I tried below code and it didn't work.

$comment_id = $facebook->api("/$post_id/comments?message='This is m message'");

An echo or print_r for $comment_id doesn't return anything.

How can I accomplish it i.e. posting comment to a post on my Facebook page using Facebook graph API for PHP? Kindly guide me in the right direction.


Solution

  • Try something like this,

    $facebook ->api('/'.$post_id.'/comments', 
     'post', 
        array(
          'access_token' => $your_access_token_variable,
          'message' => 'Your message',
        )
    );