pksunkara / buffer-alpaca
Buffer API library client for PHP
Installs: 1 996
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 2
Forks: 5
Open Issues: 4
Requires
- ext-json: *
- guzzle/guzzle: 3.7.*
This package is not auto-updated.
Last update: 2017-10-04 12:42:46 UTC
README
Buffer API library client for PHP
This library is generated by alpaca
Installation
Make sure you have composer installed.
Add the following to your composer.json
{ "require": { "pksunkara/buffer-alpaca": "*" } }
Update your dependencies
$ 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 // This file is generated by Composer require_once 'vendor/autoload.php'; // Then we instantiate a client (as shown below)
Build a client
Using this api without authentication gives an error
Oauth acess token
$client = new Buffer\Client('1a2b3', $clientOptions);
Oauth client secret
$auth = array('client_id' => '09a8b7', 'client_secret' => '1a2b3'); $client = new Buffer\Client($auth, $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_type: Default format of the response (to be used in url suffix)
Response information
All the callbacks provided to an api call will recieve the response as shown below
$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
$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
- response_type: Format of the response (to be used in url suffix)
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.
$body = 'username=pksunkara'; // >>> 'username=pksunkara'
FORM request
When the value is set to form, urlencode the body.
$body = array('user' => 'pksunkara'); // >>> 'user=pksunkara'
Information api
Returns api instance to get auxilary information about Buffer useful when creating your app.
$info = $client->info();
Services and configuration (GET /info/configuration)
Returns an object with the current configuration that Buffer is using, including supported services, their icons and the varying limits of character and schedules.
$response = $info->show($options);
Authenticated user api
Returns authenticated user api instance.
$user = $client->user();
User information (GET /user)
Returns information about the authenticated user.
$response = $user->show($options);
List of user's social profiles (GET /profiles)
Returns an array of social media profiles connected to the authenticated users account.
$response = $user->profiles($options);
Create a social update (POST /updates/create)
Create one or more new status updates.
The following arguments are required:
- text: The status update text.
- profile_ids: An array of profile id's that the status update should be sent to. Invalid profile_id's will be silently ignored.
$response = $user->createUpdate("This is an example update", array( "4eb854340acb04e870000010", "4eb9276e0acb04bb81000067" ), $options);
Links api
Returns api instance to get information about links shared through Buffer.
$link = $client->link();
Amount of link shares (GET /link/shares)
Returns an object with a the numbers of shares a link has had using Buffer.
The following arguments are required:
- url: URL of the page for which the number of shares is requested.
$response = $link->shares("http://bufferapp.com", $options);
Social profiles api
Returns a social media profile api instance.
The following arguments are required:
- id: Identifier of a social media profile
$profile = $client->profile("519fc3ca4d5e93901900002f");
Get this social profile (GET /profiles/:id)
Returns details of the single specified social media profile.
$response = $profile->show($options);
List profile's pending updates (GET /profiles/:id/updates/pending)
Returns an array of updates that are currently in the buffer for an individual social media profile.
$response = $profile->pending($options);
List profile's sent updates (GET /profiles/:id/updates/sent)
Returns an array of updates that have been sent from the buffer for an individual social media profile.
$response = $profile->sent($options);
Edit profile's updates order (POST /profiles/:id/updates/reorder)
Edit the order at which statuses for the specified social media profile will be sent out of the buffer.
The following arguments are required:
- order: An ordered array of status update id's. This can be a partial array in combination with the offset parameter or a full array of every update in the profiles Buffer.
$response = $profile->reorder(array( "4eb854340acb04e870000010", "4eb9276e0acb04bb81000067", "4eb2567e0ade04ba51000001" ), $options);
Shuffle profile's updates (POST /profiles/:id/updates/shuffle)
Randomize the order at which statuses for the specified social media profile will be sent out of the buffer.
$response = $profile->shuffle($options);
Posting schedules api
Returns scheduling api instance for social media profile.
The following arguments are required:
- id: Identifier of a social media profile
$schedule = $client->schedule("519fc3ca4d5e93901900002f");
Get profile's posting schedules (GET /profiles/:id/schedules)
Returns details of the posting schedules associated with a social media profile.
$response = $schedule->list($options);
Update profile's posting schedules (POST /profiles/:id/schedules/update)
Set the posting schedules for the specified social media profile.
The following arguments are required:
- schedules: Each item in the array is an individual posting schedule which consists of days and times to match the format return by the above method.
$response = $schedule->update(array( array( 'days' => array( "mon", "tue", "thu" ), 'times' => array( "12:45", "15:30", "17:43" ) ) ), $options);
Social updates api
Returns a social media update api instance.
The following arguments are required:
- id: Identifier of a social media update
$update = $client->update("4eb8565e0acb04bb82000004");
Get this social update (GET /updates/:id)
Returns a single social media update.
$response = $update->show($options);
List interactions of the update (GET /updates/:id/interactions)
Returns the detailed information on individual interactions with the social media update such as favorites, retweets and likes.
$response = $update->interactions($options);
Edit this update (POST /updates/:id/update)
Edit an existing, individual status update.
The following arguments are required:
- text: The status update text.
$response = $update->update("This is an edited update", $options);
Share this update (POST /updates/:id/share)
Immediately shares a single pending update and recalculates times for updates remaining in the queue.
$response = $update->share($options);
Delete this update (POST /updates/:id/destroy)
Permanently delete an existing status update.
$response = $update->destroy($options);
Move this update to top (POST /updates/:id/move_to_top)
Move an existing status update to the top of the queue and recalculate times for all updates in the queue. Returns the update with its new posting time.
$response = $update->top($options);
Contributors
Here is a list of Contributors
TODO
License
MIT
Bug Reports
Report here.
Contact
Pavan Kumar Sunkara (pavan.sss1991@gmail.com)