guzzle

Laravel 5: Guzzle with Chumper Datatable

大城市里の小女人 提交于 2019-12-24 07:32:16
问题 I was wondering if there's a way to integrate this with guzzle? I'm calling an external restful api. I'm new to Datatable so not sure if it's possible. Right now i'm just doing a foreach in my view. How to integrate this with chumper datatable? Controller public function getIndex() { $client = new \GuzzleHttp\Client(); $response = $client->get('http://api.company.com/members'); $body = json_decode($response->getBody()); $content = view('members')->with('members',$body); return Admin::view(

Upload File in chunks to URL Endpoint using Guzzle PHP

北城以北 提交于 2019-12-24 05:59:46
问题 I want to upload files in chunks to a URL endpoint using guzzle. I should be able to provide the Content-Range and Content-Length headers. Using php I know I can split using define('CHUNK_SIZE', 1024*1024); // Size (in bytes) of chunk function readfile_chunked($filename, $retbytes = TRUE) { $buffer = ''; $cnt = 0; $handle = fopen($filename, 'rb'); if ($handle === false) { return false; } while (!feof($handle)) { $buffer = fread($handle, CHUNK_SIZE); echo $buffer; ob_flush(); flush(); if (

Can I add middleware to the default Guzzle 6 HandlerStack, rather than creating a new stack?

霸气de小男生 提交于 2019-12-24 05:50:41
问题 I am using the Spatie\Crawler crawler software in a fairly standard way, like so: $client = new Client([ RequestOptions::COOKIES => true, RequestOptions::CONNECT_TIMEOUT => 10, RequestOptions::TIMEOUT => 10, RequestOptions::ALLOW_REDIRECTS => true, ]); $crawler = new Crawler($client, 1); $crawler-> setCrawlProfile(new MyCrawlProfile($startUrl, $pathRegex))-> setCrawlObserver(new MyCrawlObserver())-> startCrawling($url); I've omitted the definition of the classes MyCrawlProfile of

Cannot access localhost:8080 from laravel

大憨熊 提交于 2019-12-24 02:13:37
问题 I have a PHP application running on homestead box. This application makes calls to another app that is running on glassfish on my localhost:8080. When PHP application sends the request to localhost:8080, I am getting following error: ConnectException in RequestException.php line 49: cURL error 7: Failed to connect to localhost port 8080: Connection refused Still I can make calls to localhost:8080 from web browser.Anyone has any suggestion? 回答1: Seeing how your application is running in

Guzzle Error with Laravel. ClientException in RequestException.php line 107:

谁说我不能喝 提交于 2019-12-23 21:18:04
问题 Here is my constructor public function __construct() { $this->jar = new \GuzzleHttp\Cookie\CookieJar(); $this->guzzle_instance = new \GuzzleHttp\Client([ 'base_uri' => API_URI, 'cookies' => $this->jar ]); return $this; } Here is the function that attempts attempts to log into the API protected function processRequest($method, $sub_uri, $body = null, $headers = null) { $this->response = $this->guzzle_instance->request($method, $sub_uri, array( 'headers' => $headers, 'body' => $body )); }

Sending request with guzzle with raw data

﹥>﹥吖頭↗ 提交于 2019-12-23 16:23:28
问题 I want to send a request with guzzle that looks like this. Post man request Thing is, I always get Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: POST http://localhost:8080/project/user/login resulted in a 400 Bad Request Here is the part of the code that creates and sends the request: if (isset ($_REQUEST['username']) && isset($_REQUEST['password'])){ require '../php/vendor/autoload.php'; $myClient = new GuzzleHttp\Client(); $request = $myClient->post(

Iterating over the objects in a folder on amazon S3

柔情痞子 提交于 2019-12-23 13:13:00
问题 We have an application where in user can create his own webpages and host them.We are using S3 to store the pages as they are static.Here,as we have a limitation of 100 buckets per user,we decided to go with folders for each user inside a bucket. Now,if a user wants to host his website on his domain,we ask him for the domain name( when he starts we publish it on our subdomain ) and I have to rename the folder. S3 being a flat file system I know there are actually no folders but just delimeter

Class 'Guzzle\Http\Client' not found

我们两清 提交于 2019-12-23 10:28:31
问题 I am trying to follow up on this tutorial on sitepoint http://www.sitepoint.com/guzzle-php-http-client/ , I followed the installation step by step here http://docs.guzzlephp.org/en/latest/overview.html#installation and I'm trying to run the first simple example, but its giving me issue. I also checked my PHP version requirements(5.5): Mine is 5.6, so thats Ok. I am using a MAC, See my code below. error_reporting(E_ALL); ini_set('display_errors', 1); require_once 'vendor/autoload.php'; use

PHP Guzzle: Empty body response

假如想象 提交于 2019-12-23 09:36:55
问题 I just started experimenting with guzzle but i am getting an empty string on the response body $client = new Client([ 'base_uri' => 'http://httpbin.org', 'timeout' => 2.0, ]); $response = $client->request('GET', '', ['debug' => true]); var_dump($response->getBody()->getContents()); And the response i am getting is: * About to connect() to httpbin.org port 80 (#0) * Trying 23.22.14.18... * Connected to httpbin.org (23.22.14.18) port 80 (#0) > GET / HTTP/1.1 User-Agent: GuzzleHttp/6.2.0 curl/7

Composer autoloader not loading GuzzleHttp\ClientInterface

心已入冬 提交于 2019-12-23 07:49:52
问题 I'm trying to use Guzzle, but I'm getting the following fatal error: Fatal error: Class 'GuzzleHttp\ClientInterface' not found in /var/www/myapp/vendor/guzzlehttp/guzzle/src/functions.php on line 13 I'm autoloading with composer autoloader: require 'vendor/autoload.php'; use Guzzle\Http\Client; $client = new Client(); $requests = Array( $client->createRequest('GET', 'ams1.myapp.com:8080/api/ffmpeg_make_snapshots.php'), $client->createRequest('GET', 'ams2.myapp.com:8080/api/ffmpeg_make