Giter Site home page Giter Site logo

php-social's Introduction

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.

Usage

You can see base example.

Auth in vk.com:

// 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:

// 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:

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

Alternatively, you can download the php-social.zip file and extract it.

Read

php-social's People

Contributors

itlessons avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.