1

我正在尝试在用户墙上发布照片并标记朋友,但我得到了这个:

致命错误:未捕获的 OAuthException:(#324) 需要在第 1238 行的 /home/vhosts/somesite.com/src/base_facebook.php 中抛出上传文件

这是我的代码

<?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 回答