2017 © Pedro Peláez
 

library php-social

PHP Social Auth Library

image

itlessons/php-social

PHP Social Auth Library

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 0 Open issues
  • 2 Versions
  • 4 % Grown

The README.md

php-social

The library to make work with social networks easy. They can auth with OAuth 2.0 or OAuth 1+ protocols and retrieve user profile info. Support Vkontakte, Facebook, Twitter, Github, MailRu. Works with PHP 5.3.3 or later., (*1)

Usage

You can see base example., (*2)

Auth in vk.com:, (*3)

// config.php
$APP_ID_VK = -1; // app id
$APP_SECRET_VK = 'some secret code';
$APP_SCOPE_VK = ''; //some permissions
$REDIRECT_URL_VK = 'http://domain.ltd/auth_callback_vk.php';


// auth_vk.php
require __DIR__.'/config.php';
$auth = new \Social\Auth\AuthVk($APP_ID_VK, $APP_SECRET_VK, $APP_SCOPE_VK);
$url = $auth->getAuthorizeUrl($REDIRECT_URL_VK);
stopAndRedirect($url);

Now create callback file and get first api call:, (*4)

// auth_callback_vk.php
require __DIR__.'/config.php';
$auth = new \Social\Auth\AuthVk($APP_ID_VK, $APP_SECRET_VK, $APP_SCOPE_VK);
$token = $auth->authenticate($_REQUEST, $REDIRECT_URL_VK);

if($token == null){
    var_dump($auth->getError());
    //exit
}

//call api with access_token
$api = new \Social\Api\ApiVk($token);
$user = $api->getProfile();

//use user data

// $user->id
// $user->firstName
// $user->lastName
// $user->nickname
// $user->screenName
// $user->photoUrl
// $user->photoBigUrl
// ...

Installation

The recommended way to install php-social is through Composer. Just create a composer.json file and run the php composer.phar install command to install it:, (*5)

{
    "require": {
        "itlessons/php-social": "*"
    }
}

Alternatively, you can download the php-social.zip file and extract it., (*6)

Read

  • [Авторизация с помощью OAuth 2.0 в Вконтакте, Моем мире и Facebook] (http://www.itlessons.info/php/auth-with-oauth2-in-vk-mailru-facebook/)
  • [Авторизация на вашем сайте с помощью Github] (http://www.itlessons.info/php/auth-with-oauth2-in-github/)
  • [Авторизация и работа с Twitter Api через OAuth] (http://www.itlessons.info/php/twitter-oauth-login-and-api/)

The Versions

30/06 2014

dev-master

9999999-dev https://github.com/itlessons/php-social

PHP Social Auth Library

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

api social oauth auth vk facebook twitter github mail.ru

30/06 2014

0.0.1

0.0.1.0 https://github.com/itlessons/php-social

PHP Social Auth Library

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

api social oauth auth vk facebook twitter github mail.ru