stealthrt Posted February 16, 2014 Share Posted February 16, 2014 Hey all i am using the following code to post to a posting on my news feed: <?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 /*$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/graph-api/reference/object/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. $comment = $facebook->api('/xxxxxxxxxxx_yyyyyyyyyyyyy/comments', 'post', array( 'message' => 'testing!', ) ); What am i missing??? Link to comment https://forums.phpfreaks.com/topic/286244-posting-a-comment-on-the-news-feed-facebook-api/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.