PHP code example of joomla / facebook

1. Go to this page and download the library: Download joomla/facebook library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

joomla / facebook example snippets


use Joomla\Facebook\Facebook;

$facebook = new Facebook;

use Joomla\Facebook\Facebook;
use Joomla\Facebook\OAuth;

$options = array(
    'clientid' => $app_id,
    'clientsecret' => $app_secret,
    'redirecturi' => $callback_url,
    'sendheaders' => true,
    'authmethod' => 'get'
);

$oauth = new OAuth($options);

$facebook = new Facebook($oauth);

// Set the stored access token.
$oauth->setToken($token);

$access_token = $oauth->authenticate();

$oauth->setScope('read_stream,publish_stream');

$user = $facebook->user->getFeed($user_id);

use Joomla\Facebook\Facebook;
use Joomla\Facebook\OAuth;

$app_id = "app_id";
$app_secret = "app_secret";
$my_url = 'http://localhost/facebook_test.php';

$options = array(
    'clientid' => $app_id,
    'clientsecret' => $app_secret,
    'redirecturi' => $callback_url,
    'sendheaders' => true,
    'authmethod' => 'get'
);

$oauth = new OAuth($options);
$oauth->authenticate();

$facebook = new Facebook($oauth);

$user = $facebook->user;
$response = $user->getFeed("me");