简体   繁体   中英

schedule post on facebook page using PHP

i want to schedule post on facebook page:I am using this code

        $requestPage_info frown emoticon new FacebookRequest($session, 'GET', '/PAGEID?fields=access_token'))->execute()->getGraphObject()->asArray();
    $rtPage_info = json_decode( json_encode($requestPage_info ), true); 
    $pageToken = $rtPage_info['access_token'];
    $facebookSession = new FacebookSession($pageToken);
        if( !empty($pageToken ) ) { 
            try {
                $time_stamp= strtotime(" 900 seconds");
                $post_id = new FacebookRequest($facebookSession, 'POST',"/PAGEID/feed", array('message' => 'time stamp','published' => 'false','scheduled_publish_time' => "$time_stamp" ) )->execute()->getGraphObject();
                echo $post_id;
            } catch ( Exception $e ) { // Catch any exceptions
                $session = null;
                echo "Exception occured, code: " . $e->getCode();
                echo " with message: " . $e->getMessage(); 
            }
        }

but it is not return any id .Is anything wrong inside code?if any please give solution .

UPDATE: You didn't make execute and call getGraphObject(). Look below;

As show on that link : https://developers.facebook.com/docs/graph-api/reference/v2.2/page/feed

    $request = new FacebookRequest(
  $session,
  'POST',
  '/{page-id}/feed',
  array (
    'message' => 'This is a test message',
  )
);
$response = $request->execute();
$graphObject = $response->getGraphObject();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM