PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, February 27, 2022

[FIXED] Set video expiration with graph api

 February 27, 2022     facebook, facebook-graph-api, facebook-php-sdk, php     No comments   

Issue

I want to set an expiration date & expiration type for videos on Facebook with PHP Graph SDK (link to docs). I always get (#100) Invalid format for expiration param. I've tried serveral date formats as ISO8601, timestamp like other dates and associative arrays to pass it as an object $params['expiration']['time'] = 2018-02-04T23:57:00+0100

Whats the correct way to set up this parameter?

$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);

I'm using graph v2.11 & latest SDK.


Solution

Setting up as array was right, but with a few restrictions:

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


Answered By - Rito
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing