1

我希望我们 Facebook 页面的粉丝能够将图像发布到特定专辑。尽管该应用程序能够将图像上传到用户时间轴,但该应用程序无法将其发布到粉丝页面(公司的 Facebook 页面)中的相册。出了什么问题,或者如何更改代码以便跟踪错误。

在较早的尝试中,我能够使用类似的脚本和永不过期的令牌将图像发布到粉丝页面的墙上,但随后应用程序发布了它,我想查看用户名。

<?php
require 'facebook.php';

$app_id = "xxx";
$app_secret = "xxx";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));

$canvas_page = "http://apps.facebook.com/xxx/";
$auth_url = "https://www.facebook.com/dialog/oauth?client_id=" 
. $app_id . "&redirect_uri=" . urlencode($canvas_page)."&scope=publish_stream";

$signed_request = $_REQUEST["signed_request"];

if(isset($_FILES["source"]["name"]))
{
    try {
        $facebook->setFileUploadSupport(true);
        $response = $facebook->api(
        '/ALBUMID/photos/',
        'post',
        array(
        'message' => $_POST['message'],
        'source' => '@'.$_FILES["source"]["tmp_name"], 
        'access_token' => 'xxx'
        )
        );
    }
    catch (FacebookApiException $e) {
        error_log('Could not post image to Facebook.');
    }
}

list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);

if (empty($data["user_id"])) {
    echo("<script> top.location.href='" . $auth_url . "'</script>");
    } else {
    echo ("Welcome User: " . $data["user_id"]);
};


$signed_request = $facebook->getSignedRequest();
$user = $facebook->getUser();
$page_id = $signed_request["page"]["id"];
$page_admin = $signed_request["page"]["admin"];
$like_status = $signed_request["page"]["liked"];
$country = $signed_request["user"]["country"];
$locale = $signed_request["user"]["locale"];

echo "<br>user id = $user";
echo "<br>page id = $page_id";
echo "<br>page admin = $page_admin";
echo "<br>like status = $like_status";
echo "<br>country = $country";
echo "<br>locale = $locale";
if ($like_status) {
?>
<div id="like">
    You like us.
    <form enctype="multipart/form-data" action=" " method="POST">
        Please choose a photo:
        <input name="source" type="file"><br/><br/>
        Say something about this photo:
        <input name="message"
        type="text" value=""><br/><br/>
        <input type="submit" value="Upload" class="btn btn-primary"/><br/>
    </form>
    <?php
        if(isset($response))
        {
            echo "Image Uploaded. <a href='http://facebook.com/{$response['id']}' target='_blank'>Click here to view</a>";
        }
    ?>

</div>
<?php
}
else {
?>
<div id="niet_leuk">
    You don't like us.
</div>
<?php
}
?>
4

1 回答 1

0

这是 facebook opengraph 的一个已知错误。你可以在这里看到它的细节: https ://developers.facebook.com/bugs/246002638848837/

它被标记为低优先级,所以我不希望很快得到修复。

所以现在,您只能以页面管理员或页面本身的身份将图像发布到非用户页面。

于 2013-04-10T06:22:29.547 回答