0

我尝试使用 Facebook API 中的标记功能,但它不起作用。

这是权限代码:

$facebook->getLoginUrl(
    array(
        'canvas' => 1,
        'fbconnect' => 0,
        'req_perms' => 'user_photos, friends_photos, publish_stream,
                        offline_access, user_likes, user_photo_video_tags',
        'next' => $appCanvasPage.'index.php',
        'cancel_url' => $appCanvasPage
    )
);

这是我尝试的第一种方法:

$photoId = $userid."_".$upload_photo['id'];
$post_url = "https://graph.facebook.com/"
            .$$photoId . "/tags/" . $friendid
            . "?access_token=". $access_token
            . "&x=" . $x_coordinate 
            . "&y=" . $y_coordinate 
            . "&method=POST";
file_get_contents($post_url);

这将返回一个错误:

"message": "Unsupported post request.",
"type": "GraphMethodException",
"code": 100

我试过的第二种方法:

$fd = 'XXXX';
$tag = array(
    'tag_uid' => $fd,
    'x' => '10.0',
    'y' => '10.0'
);
$tags = array($tag0);
$facebook->api(
    array(
        'method' => 'photos.addTag',
        'pid' => $photoId,
        'tags' => json_encode($tags)
    )
);

此代码也不标记照片。

4

3 回答 3

1

好的..我找到了解决方案..可以使用此代码进行标记

$tag = array(
            'tag_uid' => $fb->getUser(),
            'x' => 0,
            'y' => 0
        );
        $tags[] = $tag;
        $image = array(
            'access_token' => $session['access_token'],
            'tags' => $tags,
        );
        $fb->setFileUploadSupport(true);
        $image['image'] = '@'.realpath($image_path);
        $fb->api('/me/photos', 'POST', $image);
于 2012-07-20T16:25:31.347 回答
0

photos.addTag是一个旧的遗留 REST API。你应该这样称呼:

$fd = 'XXXX';
$tag0 = array('to' => $fd, 'x' => '10.0', 'y' => '10.0');
$tags = array($tag0);
$facebook->api('/' . $photoId . '/tags', 'POST', $tags);
于 2012-07-19T05:55:33.100 回答
0
$post_url = "https://graph.facebook.com/"
        .$$photoId . "/tags/" . $friendid

你真的应该做一些调试,而不是仅仅“想知道”为什么会失败……</p>

你在那里写了 $$photoId,有两个 $ 符号。这就是 PHP 中所谓的“变量变量”,它会尝试访问名称为 $photoId 内容的变量——但我怀疑您的脚本中没有设置名为“$someuserid_somepictureid”的变量。

所以除了给出一个错误(如果你已经将你的 error_reporting 设置为一些明智的东西,就像我已经告诉你的那样),如果你刚刚做了一个 $post_url 的调试输出,你很容易发现它有问题……< /p>

于 2012-07-20T09:24:35.327 回答