jacksleight / coast-social
Coast component for accessing social media APIs
Requires
- php: >=5.5.0
- jacksleight/coast: ^0.7|^0.8
This package is auto-updated.
Last update: 2024-10-13 15:54:23 UTC
README
Coast Social can retrieve latest post feeds and URL statistics from various social media platforms in a standardised format. It is currently a work in progress, there are not yet any stable releases.
What's Supported?
⚫ = Supported, always present
⚪ = Supported, when present
feed
Input
- The raw parameter allows you to parse additional parameters to each providers API, refer to the relevant API documentation for more information.
Output
- The raw parameter contains the unmodified source from the API response.
urlStats
Input
A Coast\Url
object.
Output
Installation
The easiest way to install Coast Social is through Composer, by creating a file called composer.json
containing:
{ "require": { "jacksleight/coast-social": "dev-master" } }
And then running:
composer.phar install
Usage
$facebook = new Coast\Social\Provider\Facebook([ 'credentials' => [ 'appId' => '', 'appSecret' => '', 'accessToken' => '', // Get from https://developers.facebook.com/tools/explorer/ ], ]); $feed = $facebook->feed([ 'id' => '', // User/page ID 'username' => '', // User/page username ]); $stats = $facebook->stats(new Coast\Url('http://www.example.com/'));
$twitter = new Coast\Social\Provider\Twitter([ 'credentials' => [ 'consumerKey' => '', 'consumerSecret' => '', 'accessToken' => '', 'accessTokenSecret' => '', ], ]); $feed = $twitter->feed([ 'username' => '', ]);
$instagram = new Coast\Social\Provider\Instagram([ 'credentials' => [ 'accessToken' => '', ], ]); $feed = $instagram->feed();
The Instagram provider uses the Instagram Basic Display API. Use the User Token Generator to generate an access token. The Instagram Basic Display API only allows access your own data. The input id
parameter can be specified, but it is not required and will default to me
;
$pinterest = new Coast\Social\Provider\Pinterest([ 'credentials' => [ 'appId' => '', 'appSecret' => '', 'accessToken' => '', // Get from https://developers.pinterest.com/tools/access_token/ ], ]); $feed = $pinterest->feed([ 'id' => '', // Board ID ]); $stats = $pinterest->stats(new Coast\Url('http://www.example.com/'));
Aggregate
$social = new Coast\Social([ 'providers' => [ 'twitter' => $twitter, 'facebook' => $facebook, ], ]); $feed = $social->feed([ // Feeds from all providers 'twitter' => [ 'username' => '', ], 'facebook' => [ 'id' => '', ], ]); $feed = $social->feedFlat([ // Feeds from all providers merged and ordered by date 'twitter' => [ 'username' => '', ], 'facebook' => [ 'id' => '', ], ]); $stats = $social->stats(new Coast\Url('http://www.example.com/')); // Stats from all providers $stats = $social->statsFlat(new Coast\Url('http://www.example.com/')); // Stats from all providers added together
Licence
The MIT License
Copyright 2017 Jack Sleight http://jacksleight.com/
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.