-
-
Notifications
You must be signed in to change notification settings - Fork 101
Examples
Stefan Zweifel edited this page Oct 11, 2019
·
4 revisions
List of working examples. (If you have written an example in another language send us a link and we add it here).
<?php
namespace App\Services\Screeenly;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response;
class HttpClient
{
/**
* Make Request to Screenly to take screenshot of given URL
* @param string $url
* @return \GuzzleHttp\Psr7\Response
*/
public function get(string $url): Response
{
return (new Client())->request('POST', 'https://secure.screeenly.com/api/v1/fullsize', [
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
'Accept' => 'application/json',
],
'form_params' => [
'key' => 'YOUR_API_TOKEN',
'url' => $url
],
]);
}
}
$response = (new HttpClient())->get('https://en.wikipedia.org/wiki/Special:Random');
$jsonBody = json_decode($response->getBody()->getContents(), true);
$path = $jsonBody['path'];
Very simple CURL example.
https://gist.github.com/stefanzweifel/968e68785277013ac214