Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder StealthRT's Avatar
    Join Date
    Aug 2006
    Posts
    188
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Exclamation Posting a comment on the news feed [facebook api]

    Hey all i am using the following code to post to a posting on my news feed:
    Code:
    <?php
     require '../src/facebook.php';
     
     $facebook = new Facebook(array(
      'appId' => 'xxxxxxxxxxxxxxx',
      'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
      'fileUpload' => true,
      'cookie' => true
      ));
     
      $user = $facebook->getUser();
     
      if ($user) {
      try {
       $access_token  = $facebook->getAccessToken();
      $user_profile  = $facebook->api('/me');
       $comment = $facebook->api('/xxxxxxxxxxxxxx/comments',
        'POST',
       array(
        'access_token' => $access_token,
        'message' => 'testing!'
       )
      );
     } catch (FacebookApiException $e) {
      echo ($e);
      $user = null;
      }
      }
     
      <?php if ($user): ?>
       <a href="<?php echo $logoutUrl; ?>">Logout</a>
      <?php else: ?>
       <a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
      <?php endif ?>
     
      if ($user) {
      $logoutUrl = $facebook->getLogoutUrl();
      } else {
      $statusUrl = $facebook->getLoginStatusUrl();
       $params = array(
       'scope' => 'read_stream, friends_likes, email, read_mailbox, read_requests, user_online_presence, friends_online_presence, manage_notifications, publish_actions, publish_stream, user_likes, user_photos, user_status, user_videos, read_insights'
       );
      $loginUrl = $facebook->getLoginUrl($params);
      }
     
      ?>
     
      <?php print_r($user_profile); ?>
    For some reason i get this error:

    OAuthException: (#221) Photo not visible

    And i have no idea since i am posting a text comment and not even an image??

    If i comment out the code line

    Code:
    /*$comment = $facebook->api('/xxxxxxxxxxxxxx/comments',
        'POST',
      array(
        'access_token' => $access_token,
        'message' => 'testing!'
       )
       );*/
    it works just fine (as in, displays my info with user_profile). I've tried reading over the page that tells you how to use the comments https://developers.facebook.com/docs...ject/comments/and i do - it just doesn't seem to want to work?

    Using the graph API i was able to do the same thing i am trying to do via PHP so i know it works since it returns a json ID and when i refresh the page i see the "testing" comment...:



    And what makes it more odd is that, i can use the above code to comment on just a comment that doesnt have an image posted... But if i am commenting on a image that was posted then i get that error???!?!?!?

    I use this code to sussesfully post to a non-image post (as in, just someone posting text). Where xxxxxxxxxxxx is the post ID and yyyyyyyyyyyyyy is the users ID who posted the comment that i am posting my comment to.

    Code:
    $comment = $facebook->api('/xxxxxxxxxxx_yyyyyyyyyyyyy/comments',
    'post',
    array(
     'message' => 'testing!',
    )
    );
    What am i missing???
    Last edited by StealthRT; 02-17-2014 at 12:51 AM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •