使用图表API

时间:2018-01-29 13:35:50

标签: php facebook facebook-graph-api facebook-php-sdk

我想设置过期日期&使用PHP Graph SDK(link to docs)在Facebook上显示视频的到期类型。我总是得到(#100) Invalid format for expiration param。我已经尝试了几种日期格式作为ISO8601,时间戳像其他日期和关联数组一样将它作为对象传递$params['expiration']['time'] = 2018-02-04T23:57:00+0100

设置此参数的正确方法是什么?

$this->handle=new \Facebook\Facebook([
    'app_id'=>'xxx',
    'app_secret'=>'xxx',
    'default_graph_version'=>'v2.11',
    'default_access_token'=>$session
]);

// copied from print_r
$params = Array(
    [title] => videoname
    [name] => videoname
    [content_category] => ENTERTAINMENT
    [description] => some description text
    [embeddable] => 1
    [file_size] => 29089069
    [thumb] => Facebook\FileUpload\FacebookFile Object
        (
            [path:protected] => 7SQNP1186922FBPx2.jpg
            [maxLength:Facebook\FileUpload\FacebookFile:private] => -1
            [offset:Facebook\FileUpload\FacebookFile:private] => -1
            [stream:protected] => Resource id #164
        )

    [secret] => 
    [published] => 
    [no_story] => 
    [unpublished_content_type] => SCHEDULED
    [scheduled_publish_time] => 1517400300
    [expiration] => 2018-02-04T23:57:00+0100
    [expiration_type] => hide
)

$this->handle->post('/'.$fbpageID.'/videos',$params,$token);

我正在使用图形v2.11&最新的SDK。

1 个答案:

答案 0 :(得分:0)

设置为数组是正确的,但有一些限制:

$params['published'] = true; // video must be already published
$params['expiration'] = [
    'time' => 1517400300, // as UTC timestamp
    'type' => 'expire_only' // required property
];