1

ユーザーウォールに写真を投稿して友達にタグ付けしようとしていますが、これを取得しています:

致命的なエラー: Uncaught OAuthException: (#324) Requires upload file throws in /home/vhosts/somesite.com/src/base_facebook.php 行 1238

これは私のコードです

<?php
require_once "./src/facebook.php";

$app_id = "xxxxxxxx";
$app_secret = "xxxxxxxxxx";

// Init facebook api.
$facebook = new Facebook(array(
        'appId' => $app_id,
        'secret' => $app_secret,
        'cookie' => true
));

// Get the url to redirect for login to facebook
// and request permission to write on the user's wall.
$login_url = $facebook->getLoginUrl(
    array('scope' => 'publish_stream')
);

$loginUrl = $facebook->getLoginUrl($params);


// If not authenticated, redirect to the facebook login dialog.
// The $login_url will take care of redirecting back to us
// after successful login.
if (! $facebook->getUser()) {
    echo <<< EOT
<script type="text/javascript">
top.location.href = "$login_url";
</script>;
EOT;

    exit;
}

// Do the wall post.
$args = array(
  'message' => 'Test Message',
  'image'   => '@' . realpath('http://imageurl.com'),
  'tags'    => array(
     array(
      'tag_uid'=> $friend1_uid,
      'x'      => $x1,
      'y'      => $y1,
     ),
     array(
      'tag_uid' => $friend2_uid,
      'x'       => $x2,
      'y'       => $y2,
     ),/*...*/
   ),
);

$data = $facebook->api('/me/photos', 'post', $args);

// Upload Support.
$facebook = new Facebook(array(
  /*..*/
  'fileUpload'  => true,
));
?>
4

1 に答える 1

0
'image'   => '@' . realpath('http://imageurl.com'),

realpath はファイル システムパス用であり、URL 用ではありません。

それをローカル ファイル システム パスに変更するか、公開されている HTTP URL から写真をアップロードする場合は、url代わりにパラメーター名を使用sourceし、URL を値として指定します。

于 2013-03-27T14:17:48.820 に答える