Skip to content

pavellee/common

 
 

Repository files navigation

SocialConnect Common

Build Status Scrutinizer Code Quality Code Coverage Dependency Status License

Entity

  • User
  • Friend

You can instance and setup fields for entity

$user = new \SocialConnect\Common\Entity\User();
$user->id = 12345;
$user->firstname = 'Dmitry';
$user->lastname = 'Patsura';

var_dump($user);

Http\Client

You can use Curl client

$httpClient = new SocialConnect\Common\Http\Client\Curl();

or Guzzle wrapper for GuzzleHttp library

$httpClient = new SocialConnect\Common\Http\Client\Guzzle();

Build Client for your REST application

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;
  }
}

Next you can use it

$client = new MySocialNetworkClient($appId, $appSecret);
$client->setHttpClient(new SocialConnect\Common\Http\Client\Curl());

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

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

License

This project is open-sourced software licensed under the MIT License.

See the LICENSE file for more information.

Packages

No packages published

Languages

  • PHP 100.0%