# social-share-php Social Share API Client API library client for PHP __This library is generated by [alpaca](https://github.com/pksunkara/alpaca)__ ## Installation Make sure you have [composer](https://getcomposer.org) installed. Add the following to your composer.json ```js { "require": { "linpar/social-share-api-client": "*" } } ``` Update your dependencies ```bash $ php composer.phar update ``` > This package follows the `PSR-0` convention names for its classes, which means you can easily integrate these classes loading in your own autoloader. #### Versions Works with [ 5.4 / 5.5 ] ## Usage ```php <?php // This file is generated by Composer require_once 'vendor/autoload.php'; // Then we instantiate a client (as shown below) ``` ### Build a client ##### Without any authentication ```php $client = new SocialShareAPIClient\Client(); // If you need to send options $client = new SocialShareAPIClient\Client(array(), $clientOptions); ``` ### Client Options The following options are available while instantiating a client: * __base__: Base url for the api * __api_version__: Default version of the api (to be used in url) * __user_agent__: Default user-agent for all requests * __headers__: Default headers for all requests * __request_type__: Default format of the request body ### Response information __All the callbacks provided to an api call will recieve the response as shown below__ ```php $response = $client->klass('args')->method('args', $methodOptions); $response->code; // >>> 200 $response->headers; // >>> array('x-server' => 'apache') ``` ##### JSON response When the response sent by server is __json__, it is decoded into an array ```php $response->body; // >>> array('user' => 'pksunkara') ``` ### Method Options The following options are available while calling a method of an api: * __api_version__: Version of the api (to be used in url) * __headers__: Headers for the request * __query__: Query parameters for the url * __body__: Body of the request * __request_type__: Format of the request body ### Request body information Set __request_type__ in options to modify the body accordingly ##### RAW request When the value is set to __raw__, don't modify the body at all. ```php $body = 'username=pksunkara'; // >>> 'username=pksunkara' ``` ##### JSON request When the value is set to __json__, JSON encode the body. ```php $body = array('user' => 'pksunkara'); // >>> '{"user": "pksunkara"}' ``` ## Contributors Here is a list of [Contributors](https://github.com/linpar/social-share-php/contributors) ### TODO ## License MIT ## Bug Reports Report [here](https://github.com/linpar/social-share-php/issues). ## Contact Nitish Gundherva (nitish.gundherva@nsitonline.in)