Facebook php schedule post - 错误意外异常

时间:2014-05-20 15:00:04

标签: php facebook facebook-graph-api

除非我尝试安排帖子,否则我有一个用于发布到托管页面的脚本。它失败了

Array ( [error] => Array ( [message] => An unexpected error has occurred. Please retry your request later. [type] => OAuthException [code] => 2 ) )

我遇到了这个Facebook Graph API error when posting scheduled post on Business page,说明这可能是"链接"但没有指定哪个链接。但我尝试了所有这些,但仍然遇到了同样的错误。

还有一个侧面问题....页面访问令牌是否过期?这些似乎有些混乱。

    foreach($_POST['fb'] as $key=>$code){

    $facebookpage= $key;
    $facebookaccesstoken= $code;

    $newfacebook = new Facebook(array(
        'appId'  => $appId,
        'secret' => $appSecret
        )); 

$time= time();
$newtime= $time +13600;

$attachment=array(
    'access_token'=> $facebookaccesstoken,
    'published' => false,
    'scheduled_publish_time'=> $newtime,
    'message'=> "new sasa posting me!",//user message
    'name'=> 'Anyone sasa interested in this? Check out my advert!',//title
    'link'=> 'http://testserverdavideec.mx.nf/wp-content/uploads/2014/05/user53734efe383247.67413395boats.jpg', // link to advert
    'description'=> 'myadvert asa brings the milkshakes',//inner ad
    'picture'=>'http://testserverdavideec.mx.nf/wp-content/uploads/2014/05/user53734efe383247.67413395boats.jpg',//picture url if empty= site logo
    'actions'=>array(array(
        'name'=>'dshjs',
        'link'=>'http://testserverdavideec.mx.nf/wp-content/uploads/2014/05/user53734efe383247.67413395boats.jpg'
    ))
);
$post_url='/'.$facebookpage.'/feed';

try{
    $result=$newfacebook->api($post_url,'POST',$attachment);
    echo '<h1> result=</h1>';    var_dump($result);
} catch (FacebookApiException $e) {
print_r($e);
} 



}

1 个答案:

答案 0 :(得分:0)

根据the official documentation不支持已发布操作字段一起使用。所以你可以使用scheduled_publish_time或者动作,但两者都不会去。

我希望它有所帮助。