Skip to content

Instantly share code, notes, and snippets.

@JamesTheHacker
Created November 17, 2016 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesTheHacker/1159446b05ceaef588ccf4f7603d69b3 to your computer and use it in GitHub Desktop.
Save JamesTheHacker/1159446b05ceaef588ccf4f7603d69b3 to your computer and use it in GitHub Desktop.
<?php
// {NONE, LIKE, LOVE, WOW, HAHA, SAD, ANGRY, THANKFUL}
require __DIR__ . '/vendor/autoload.php';
use Intervention\Image\ImageManagerStatic as Image;
$pageID = '';
$accessToken = '';
$appID = '';
$appSecret = '';
$fb = new \Facebook\Facebook([
'app_id' => $appID,
'app_secret' => $appSecret,
'default_graph_version' => 'v2.8'
]);
/*
$request = $fb->request('GET', '/' . $pageID . '/reactions', [], $accessToken);
try {
$response = $fb->getClient()->sendRequest($request);
} catch(\Facebook\Exceptions\FacebookResponseException $e) {
die('GraphAPI Error: ' . $e->getMessage());
}
$response = json_decode($response->getBody())->data;
$reactionsCount = array_reduce($response, function($carry, $item) {
$carry[$item->type] += 1;
return $carry;
}, [ 'LIKE' => 0, 'LOVE' => 0, 'HAHA' => 0]);
*/
$reactionsCount = [
'LIKE' => 0,
'LOVE' => 2,
'HAHA' => 9
];
while(true) {
$img = Image::make(__DIR__ . '/images/background.jpg');
$img->text($reactionsCount['LIKE'], 198, 400, function($font) {
$font->file('/Library/Fonts/MyriadPro-Bold.otf');
$font->size(36);
$font->color('#FFF');
$font->align('center');
});
$img->text($reactionsCount['LOVE'], 318, 400, function($font) {
$font->file('/Library/Fonts/MyriadPro-Bold.otf');
$font->size(36);
$font->color('#FFF');
$font->align('center');
});
$img->text($reactionsCount['HAHA'], 442, 400, function($font) {
$font->file('/Library/Fonts/MyriadPro-Bold.otf');
$font->size(36);
$font->color('#FFF');
$font->align('center');
});
//$img->save('img_0.jpg');
echo $img->stream();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment