PHP Classes

File: examples/facebook_post.php

Recommend this page to a friend!
  Classes of Chun-Sheng, Li   PHP Social Network Sync   examples/facebook_post.php   Download  
File: examples/facebook_post.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Social Network Sync
Synchronize post feeds between social networks
Author: By
Last change:
Date: 7 months ago
Size: 839 bytes


Class file image Download
* This PHP program is to post the feed via Facebook graph API.

require_once __DIR__.'/../vendor/autoload.php';

$key = parse_ini_file(__DIR__.'/../api-key.ini');
$appId = $key['app_id'];
$appSecret = $key['app_secret'];
$userToken = $key['user_access_token'];
$fb = new \Facebook\Facebook([
'app_id' => $appId,
'app_secret' => $appSecret,
'default_graph_version' => 'v2.10',
'default_access_token' => $userToken,

$response = $fb->post('/me/feed', [
'message' => 'upgrading the facebook-php-sdk from-v3.x to v5.x',
'link' => '',

// more details about accessing the $response object
$httpCode = $response->getHttpStatusCode();