PHP code example of socialconnect / common

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

    

socialconnect / common example snippets


use SocialConnect\Common\ClientAbstract;

class MySocialNetworkClient extends ClientAbstract
{
  public function requestMethod($method, $parameters)
  {
    //...
  }
  
  public function getUser($id)
  {
    $result = $this->requestMethod('/user/get/', $id);
    if ($result) {
      $user = new User();
      $user->id = $result->id;
      //...
      
      return $user;
    }
    
    return false;
  }
}

$client = new MySocialNetworkClient($appId, $appSecret);
// You can use any client that implements Psr\Http\Client\ClientInterface
$client->setHttpClient(new \SocialConnect\HttpClient\Curl());

$user = $client->getUser(1);

//Custom rest methods
$client->requestMethod('myTestMethod', []);
$client->requestMethod('myTest', []);