PHP code example of jacksleight / coast-social
1. Go to this page and download the library: Download jacksleight/coast-social library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jacksleight / coast-social example snippets
$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();
$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/'));
$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