뉴스피드에 댓글 올리기 (Posting a comment on the news feed)


문제 설명

뉴스피드에 댓글 올리기 (Posting a comment on the news feed)

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 here and i do ‑ it just doesn't seem to want to work?

What am i missing???

update

using the graph API i was able to do the same thing i am trying to do via PHP so i know it works...:


참조 솔루션

방법 1:

I know it's an old question but...

First, for tests the same enviroment, you have to use your app token, not the Graph API Explorer. Otherwise, you're testing the API with all the permissions.

Second, your problem must be a permission thing (that's why it's working on the API Explorer). You should:

  1. Ask for publish_permission on the login (not recommended) or,
  2. Ask for publish_permission when the user is ready to send the comment.

    • More information about this: Optimizing Permissions Requests
    • Here the permissions that you need: Publishing Comments Permissions

As a general rule, when you see a OAuthException, you are having a permission issue.

If the post is photo type, you're going to need a user_photos permission.

(by StealthRTelecay)

참조 문서

  1. Posting a comment on the news feed (CC BY‑SA 3.0/4.0)

#facebook-php-sdk #facebook-comments #PHP #facebook






관련 질문

앱 사용자의 담벼락에 자신으로 게시하려면 액세스 토큰이 필요합니까? (Do you need an access token to post on app user's wall as themself?)

onclick 속성을 사용하여 어떻게 벽에 게시할 수 있습니까? (how can i post on a wall using onclick attribute?)

사용자의 담벼락에 게시하고 권한을 요청하는 다른 방법이 있습니까? (Are there different ways to post to user's wall and ask for permissions?)

모바일 장치에서 Facebook PHP SDK에 문제가 있음 (Having trouble with Facebook PHP SDK on mobile devices)

하나의 앱에서 각 페이지에 대해 다른 facebook 보안 페이지 탭 URL을 추가하는 방법 (How to add diffrent facebook Secure Page Tab URL for each page in one app)

모바일 클라이언트에서 서버 및 프로세스로 facebook 액세스 토큰 전달 (Pass facebook access token from mobile client to server and process)

페이지 팔로워 뉴스 피드에 Facebook 팬 페이지 콘텐츠가 표시되지 않음 (Facebook Fan page content not showing in page followers news feed)

이미지 없이 FB 공유 대화 상자 만들기 (Create FB share dialog without image)

Facebook 오류 #100: 사진 URL이 제공된 경우 링크를 제공해야 합니다. (Facebook Error #100 : A link must be provided if a picture URL is given)

맞춤 이벤트에서 웹사이트 맞춤 타겟을 만들려면 어떻게 해야 합니까? (How do I create a website Custom Audience from a custom event?)

수명이 긴 토큰을 얻는 동안 신뢰할 수 없는 결과 (Unreliable results while obtaining long-lived token)

갑자기 주석 플러그인 코드가 주석 상자를 표시하지 않습니다 (Suddenly Comments Plugin code is not showing commenting box)







코멘트