guzzle

How to get past login screen on Guzzle call

假如想象 提交于 2019-11-29 07:00:16
I have to send information to an external website using cURL. I set up Guzzle on my Laravel application. I have the basics set up, but according to the documentation of the website, there is an action that's required for the username and password. How can I pass the 'action' along with the credentials needed to log in and get access? The website states: curl [-k] –dump-header <header_file> -F “action=login” -F “username=<username>” -F “password=<password>” https://<website_URL> My controller: $client = new \GuzzleHttp\Client(); $response = $client->get('http://website.com/page/login/', array(

Guzzle cookies handling

狂风中的少年 提交于 2019-11-29 04:02:47
问题 I'm building a client app based on Guzzle. I'm getting stucked with cookie handling. I'm trying to implement it using Cookie plugin but I cannot get it to work. My client application is standard web application and it looks like it's working as long as I'm using the same guzzle object, but across requests it doesn't send the right cookies. I'm using FileCookieJar for storing cookies. How can I keep cookies across multiple guzzle objects? // first request with login works fine $cookiePlugin =

Guzzle returns cURL error 3: <url> malformed

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 03:06:41
I want to try out the guzzle library and am following through their quickstart tutorial to make http requests to an api. Yet it doesn't seem to work, because I get the following error: cURL error 3: <url> malformed Since I have never worked with cURL before, I don't even know how to respond to that error message. Here is my code with the request I am making: $client = new Client(); $client->get('/', ['verify' => true]); $response = $client->get('https://api.github.com/'); dd($response); I am using the Laravel 5 framework and calling the index method in my HomeController. Also am using WAMP. I

Guzzle Curl Error 60 SSL unable to get local issuer

浪子不回头ぞ 提交于 2019-11-29 01:56:27
问题 Trying to use the YouTube API v3 to get some video(s) information, using Guzzle in Symfony2 using Service Descriptors. When I run the script, I get this: [curl] 60: SSL certificate problem: unable to get local issuer certificate [url] https://www.googleapis.com/youtube/v3/videos?id=2xbVbCoHBgA&part=snippet&key={MY_KEY} 500 Internal Server Error - CurlException My descriptor looks like this: { "name": "YouTube", "baseUrl": "https://www.googleapis.com", "apiVersion": "v3", "description":

Upload file using Guzzle 6 to API endpoint

旧巷老猫 提交于 2019-11-29 01:12:24
I am able to upload a file to an API endpoint using Postman. I am trying to translate that into uploading a file from a form, uploading it using Laravel and posting to the endpoint using Guzzle 6. Screenshot of how it looks in Postman (I purposely left out the POST URL) Below is the text it generates when you click the "Generate Code" link in POSTMAN: POST /api/file-submissions HTTP/1.1 Host: strippedhostname.com Authorization: Basic 340r9iu34ontoeioir Cache-Control: no-cache Postman-Token: 6e0c3123-c07c-ce54-8ba1-0a1a402b53f1 Content-Type: multipart/form-data; boundary=---

Can Goutte/Guzzle be forced into UTF-8 mode?

隐身守侯 提交于 2019-11-29 00:13:10
I'm scraping from a UTF-8 site, using Goutte , which internally uses Guzzle. The site declares a meta tag of UTF-8, thus: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> However, the content type header is thus: Content-Type: text/html and not: Content-Type: text/html; charset=utf-8 Thus, when I scrape, Goutte does not spot that it is UTF-8, and grabs data incorrectly. The remote site is not under my control, so I can't fix the problem there! Here's a set of scripts to replicate the problem. First, the scraper: <?php require_once realpath(__DIR__ . '/..') . '/vendor/goutte

Guzzle Curl Error 60 SSL unable to get local issuer

[亡魂溺海] 提交于 2019-11-28 21:14:05
Trying to use the YouTube API v3 to get some video(s) information, using Guzzle in Symfony2 using Service Descriptors. When I run the script, I get this: [curl] 60: SSL certificate problem: unable to get local issuer certificate [url] https://www.googleapis.com/youtube/v3/videos?id=2xbVbCoHBgA&part=snippet&key= {MY_KEY} 500 Internal Server Error - CurlException My descriptor looks like this: { "name": "YouTube", "baseUrl": "https://www.googleapis.com", "apiVersion": "v3", "description": "YouTube GData Graph API", "operations": { "GetVideos": { "httpMethod": "GET", "uri": "/youtube/v3/videos",

How to perform multiple Guzzle requests at the same time?

一个人想着一个人 提交于 2019-11-28 17:55:25
I can perform single requests using Guzzle and I'm very pleased with Guzzle's performance so far however, I read in the Guzzle API something about MultiCurl and Batching. Could someone explain to me how to make multiple requests at the same time? Async if possible. I don't know if that is what they mean with MultiCurl. Sync would also be not a problem. I just want to do multiple requests at the same time or very close (short space of time). Michael Dowling From the docs: http://guzzle3.readthedocs.org/http-client/client.html#sending-requests-in-parallel For an easy to use solution that returns

Handle Guzzle exception and get HTTP body

扶醉桌前 提交于 2019-11-28 15:26:56
I would like to handle errors from Guzzle when the server returns 4xx and 5xx status codes. I make a request like this: $client = $this->getGuzzleClient(); $request = $client->post($url, $headers, $value); try { $response = $request->send(); return $response->getBody(); } catch (\Exception $e) { // How can I get the response body? } $e->getMessage returns code info but not the body of the HTTP response. How can I get the response body? sebbo Guzzle 3.x Per the docs , you can catch the appropriate exception type ( ClientErrorResponseException for 4xx errors) and call its getResponse() method to

How to get email from facebook through Guzzle in laravel?

我怕爱的太早我们不能终老 提交于 2019-11-28 10:38:56
问题 I am using below code to login via facebook in laravel. Referring https://scotch.io/tutorials/token-based-authentication-for-angularjs-and-laravel-apps for token based authentication and using https://github.com/sahat/satellizer for social media integration. $params = [ 'code' => $request->input('code'), 'client_id' => $request->input('clientId'), 'redirect_uri' => $request->input('redirectUri'), 'client_secret' => 'XXXXXXXXXXXXXXXXXXX' /*'client_secret' => Config::get('app.facebook_secret')*