PHP code example of mmanos / laravel-social

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

    

mmanos / laravel-social example snippets


'providers' => array(
	// ...
	'Mmanos\Social\SocialServiceProvider',
)

'aliases' => array(
	// ...
	'Social' => 'Mmanos\Social\Facades\Social',
)

$service = Social::service('facebook');

$service = Social::service('facebook', 'http://example.com');

return Redirect::to((string) $service->getAuthorizationUri());

use Mmanos\Social\SocialTrait;

class User extends Eloquent
{
	use SocialTrait;
	
}

<a href="{{ route('social-login', array('twitter')) }}">
	Log in with Twitter
</a>

<a href="{{ route('social-login', array('twitter')) }}?onsuccess=/account&onerror=/login">
	Log in with Twitter
</a>

<a href="{{ route('social-connect', array('twitter')) }}">
	Connect Your Twitter Account
</a>

$providers = Auth::user()->providers;

if (Auth::user()->hasProvider('twitter')) {
	//
}

$provider = Auth::user()->provider('twitter');

$result = Auth::user()->provider('twitter')->request('account/verify_credentials.json');

'create_user' => function ($data) {
	$user = new User;
	$user->email = array_get($data, 'email');
	$user->password = Hash::make(Str::random());
	$user->location = array_get($data, 'location'); // Only passed by certain providers.
	$user->save();
	
	return $user->id;
},

	'fetch_user_info' => function ($service) {
		$result = json_decode($service->request('account/verify_credentials.json'), true);
		return array(
			'id'         => array_get($result, 'id'),
			'email'      => null,
			'first_name' => array_get(explode(' ', array_get($result, 'name')), 0),
			'last_name'  => array_get(explode(' ', array_get($result, 'name')), 1)
			'location'   => array_get($result, 'location'),
		);
	},

'user_validation' => array(
	'email'      => ' '

{{ HTML::style('/packages/mmanos/laravel-social/css/socialbuttons.css') }}

<a href="{{ route('social-login', array('twitter')) }}" class="btn btn-social btn-twitter">
	<i class="fa fa-twitter"></i> Log in with Twitter
</a>
<a href="{{ route('social-login', array('twitter')) }}" class="btn btn-social-icon btn-twitter">
	<i class="fa fa-twitter"></i>
</a>
console
$ php artisan config:publish mmanos/laravel-social
console
$ php artisan migrate:publish mmanos/laravel-social
$ php artisan migrate
console
$ php artisan asset:publish mmanos/laravel-social