PHP Classes

File: examples/facebook.php

Recommend this page to a friend!
  Classes of Chun-Sheng, Li   PHP Social Network Sync   examples/facebook.php   Download  
File: examples/facebook.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: 1 year ago
Size: 699 bytes
 

Contents

Class file image Download
<?php
/*
* This is about the Facebook posting feeed sample code
*/

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',
]);

$helper = $fb->getRedirectLoginHelper();
$permissions = ['email', 'publish_actions']; // Optional permissions
$loginUrl = $helper->getLoginUrl('https://peterli.website/social-sync/examples/fb_callback.php', $permissions);
echo
'<a href="' . htmlspecialchars($loginUrl) . '">Log in with Facebook!</a>';