https://github.com/socialconnect/common
[READ-ONLY] Subtree split of the SocialConnect Common Component
https://github.com/socialconnect/common
Last synced: about 1 year ago
JSON representation
[READ-ONLY] Subtree split of the SocialConnect Common Component
- Host: GitHub
- URL: https://github.com/socialconnect/common
- Owner: SocialConnect
- Created: 2014-08-10T15:45:06.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2020-06-09T10:01:51.000Z (about 6 years ago)
- Last Synced: 2025-04-13T01:05:50.661Z (about 1 year ago)
- Language: PHP
- Homepage: https://socialconnect.lowl.io
- Size: 124 KB
- Stars: 6
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Common Component
================
## Build `Client` for your REST application
```php
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
```php
$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', []);
```