PHP code example of mezon / social-network

1. Go to this page and download the library: Download mezon/social-network 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/ */

    

mezon / social-network example snippets


$facebook = new \Mezon\SocialNetwork\Auth\Facebook([
	'client_id' => 'client id from the Facebook application',
	'client_secret' => 'client secret from the Facebook application',
	'redirect_uri' => 'URI of your web application on wih user will be redirected after authorization on Facebook'
]);

print('<a href="'.$facebook->getLink().'"Sign In</a>a>');

// your redirect_uri must process code

if($facebook->auth($_GET['code'])) {
	// authorization was successfull
}
else {
	// an error have occured
}

var_dump($facebook->userInfo);
// here:
// [
//	'id' => 'user id',
//	'first_name' => 'user first name',
//	'last_name' => 'user last name',
//	'email' => 'user email, but looks like Facebook has forbidden to fetch this info, so dont rely on this field',
//	'picture' => 'user avatar'
// ]