PHP code example of nggiahao / facebook-graph

1. Go to this page and download the library: Download nggiahao/facebook-graph 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/ */

    

nggiahao / facebook-graph example snippets

 php
use Nggiahao\Facebook\Facebook;
use Nggiahao\Facebook\Model;

class UsageExample
{
    public function run()
    {
        $accessToken = 'xxx';

        $graph = new Facebook();
        $graph->setAccessToken($accessToken);

        $user = $graph->request("GET", "/me")
                      ->returnEmtry(Model\User::class) //or return Collection

        echo "Hello, I am $user->name ";
    }
}