【问题标题】:PHP stream post on news working but picture not uploadingPHP流发布新闻工作但图片不上传
【发布时间】:2012-04-20 06:22:39
【问题描述】:
$profile_id = $userInfo['id'];
            $picLocal = "https://xxxxxxxxxx/logo.jpg";
                $attachment = array('access_token' => $decodedSignedRequest['oauth_token'],'message' => $userInfo['name'].' is in the draw to win a Free wine for a year',
             'name' => "Oliver's taringa",
             'link' => $fbconfig['appPageUrl'],
             'description' => 'Oliver\'s Taranga in McLaren Vale is home to the ultra-premium HJ Reserve Shiraz and has supplied grapes for the illustrious Penfolds Grange, arguably the pinnacle of achievement for Shiraz growers in Australia. So join their community to go in the draw to win a years worth of amazing wine!',
             'picture' => $picLocal
                );
                if(!($sendMessage = $facebook->api('/'.$profile_id.'/feed/','post',$attachment))){
                $errors= error_get_last();
                echo "Facebook publish error: ".$errors['type'];
                echo "<br />\n".$errors['message'];
                }
            }   

在 3 天之前,此代码适用于所有应用程序。但从过去 3 天开始,我看到了消息等帖子,只有我们无法在新闻上看到的图片。

http://i.stack.imgur.com/n06Jj.jpg

【问题讨论】:

  • 我也遇到了同样的问题,我会留意这里以防万一有人发布解决方案...

标签: facebook-graph-api feed


【解决方案1】:

下面的代码很适合我。

$data = array(
            "link" => $link,
            "access_token" => $user_access_token,
            "picture" => $image,
            "name"=> $title,
            "description"=> $description
    );


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/".$userId."/feed");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$op = curl_exec($ch);
if (!$op) {
    echo "Curl Error : ".curl_error($ch);
    curl_close($ch);
    exit;
}

curl_close($ch);
$res = get_object_vars(json_decode((string)$op));
print_r($res);

【讨论】:

    猜你喜欢
    • 2016-07-14
    • 1970-01-01
    • 2017-01-01
    • 2019-02-06
    • 1970-01-01
    • 2013-09-23
    • 2017-05-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多