guzzle

laravel : cURL error 60: SSL certificate unable to get local issuer certificate

依然范特西╮ 提交于 2019-12-23 04:45:31
问题 Ubuntu: 15.04 Laravel: 5.4.32 GuzzleHttp\Guzzle: ~6.0 Hi there I have the following error when I am trying to reset a password using Laravel's built in authentication. When I enter my email and hit reset I get... GuzzleHttp\Exceptions\RequestException cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) I have googled this error and it from everything I have read I have tried the following, all of which have not

URI templates in Guzzle 5?

给你一囗甜甜゛ 提交于 2019-12-23 02:42:19
问题 Guzzle 3 had URI templates that allowed for a request definition such as $request = $client->get(array('http://example.com{+path}{/segments*}{?query,data*}', array( 'path' => '/foo/bar', 'segments' => array('one', 'two'), 'query' => 'test', 'data' => array( 'more' => 'value' ) ))); In my case, i am looking to exploit the 'segments' , but Guzzle 5 doesn't seem to define this. Instead the closest ive come across was * $client = new Client([ * 'base_url' => [ * 'http://www.foo.com/{version}/', *

POST Request works with Postman, but not with Guzzle

吃可爱长大的小学妹 提交于 2019-12-22 05:32:01
问题 In my Laravel application, I periodically need to POST data to an API using Guzzle. The API users a bearer token to authenticate, and requests and accepts raw json. To test, I accessed the API using Postman, and everything worked wonderfully. Postman Headers: Accept:application/json Authorization:Bearer [token] Content-Type:application/json And Postman Body: { "request1" : "123456789", "request2" : "2468", "request3" : "987654321", "name" : "John Doe" } Postman returns a 200, and a JSON

Incrementally add requests to a Guzzle 5.0 Pool (Rolling Requests)

纵饮孤独 提交于 2019-12-22 00:15:36
问题 I'm using Guzzle to fetch a large number of URLs in parallel (or asynchronously) using a pool: $client = new GuzzleHttp\Client([ 'base_url' => 'http://httpbin.org', ]); $requests = []; for ($i = 0; $i < 8; ++$i) { $requests[] = $client->createRequest('GET', '/get'); } $pool = new GuzzleHttp\Pool($client, $requests, [ 'pool_size' => 4, 'complete' => function (GuzzleHttp\Event\CompleteEvent $event) { var_dump($event->getRequest()->getUrl()); }, ]); $pool->wait(); var_dump(count($requests)); If

Curl error 7 on vagrant using guzzle

让人想犯罪 __ 提交于 2019-12-21 23:04:28
问题 I've get an Curl error 7: Failed to connect to site1.local port 8000: Connection refused , when i call it from another local site (site2.local). Both sites run on the same Vagrant box. When i replace the url to an url of an external site (eg. google.com), there is no problem in connecting. Why does vagrant refuse a call from his own? I searched the problem, but couldn't find any solution to this. Is there a way to call to another site on the same server using curl? edit: Vagrantfile: Vagrant

Using Guzzle promises asyncronously

▼魔方 西西 提交于 2019-12-21 12:29:01
问题 I am attempting to use guzzle promises in order to make some http calls, to illustrate what I have, I have made this simple example where a fake http request would take 5 seconds: $then = microtime(true); $promise = new Promise( function() use (&$promise) { //Make a request to an http server $httpResponse = 200; sleep(5); $promise->resolve($httpResponse); }); $promise2 = new Promise( function() use (&$promise2) { //Make a request to an http server $httpResponse = 200; sleep(5); $promise2-

Proper way to send (POST) xml with guzzle 6

血红的双手。 提交于 2019-12-21 03:49:09
问题 I want to perform a post with guzzle sending an xml file. I did not find an example. What I 've done so far is : $xml2=simplexml_load_string($xml) or die("Error: Cannot create object"); use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request; $client = new Client(); // $request = new Request('POST', $uri, [ 'body'=>$xml]); $response = $client->send($request); // //$code = $response->getStatusCode(); // 200 //$reason = $response->getReasonPhrase(); // OK // echo $response->getBody(); No matter what

Moving Curl client ssl to Guzzle

一曲冷凌霜 提交于 2019-12-21 03:48:12
问题 I'm using Guzzle v3.9.2 with both php 5.3 and php 5.5. I have the following working curl code that uses an ssl client certificate: $url = "https://example.com/"; $cert_file = '/path/to/certificate.pem'; $ch = curl_init(); $options = array( CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_URL => $url , CURLOPT_SSLCERT => $cert_file , ); curl_setopt_array($ch , $options); $output = curl_exec($ch); if (!$output) { echo "Curl Error : " . curl_error($ch); } else { echo

Guzzle get file and forward it

寵の児 提交于 2019-12-20 17:28:10
问题 I have a web-service that gets a file and returns it to the user (based on Symfony). Ever since I used curl to do this. I just found guzzlehttp and it seems great. However, I do not know how to do this with guzzle without saving the downloaded file (xml or txt) to a local file, read it from the file system a returning it to the user. I want to do this without saving to the file system. 回答1: public function streamAction() { $response = $client->request( 'GET', 'http://httpbin.org/stream-bytes

How to use oAuth with Guzzle 5 (or, better, with Guzzle 6)

亡梦爱人 提交于 2019-12-19 04:02:55
问题 I'm trying to connect to the WooCommerce API using Guzzle 5 (Guzzle 6 seems not has oAuth options o.O). Woocommerce requires the oAuth authentication method to work. This is the code I'm using: <?php /** * Example of usage of Guzzle 5 to get information * from a WooCommerce Store. */ require('../vendor/autoload.php'); use GuzzleHttp\Client; use GuzzleHttp\Subscriber\Oauth\Oauth1; use GuzzleHttp\Exception\RequestException; $consumer_key = 'my_consumer_key'; // Add your own Consumer Key here