guzzle

Google API throwing error when verifying token

时间秒杀一切 提交于 2020-01-15 09:52:22
问题 I've been trying to use the Google-API for Google Sign-In, but when I do // $token is set to a correct value beforehand require_once 'inc/google-api/vendor/autoload.php'; $client = new Google_Client(['client_id' => '280452639491-s53psco36kn5cm3nitma4gpqsq9ik3ao.apps.googleusercontent.com']); $payload = $client->verifyIdToken($token); as instructed by google, this error pops up: Fatal error: Uncaught exception 'RuntimeException' with message 'Guzzle requires cURL, the allow_url_fopen ini

Class 'GuzzleHttp\Client' not found

孤街醉人 提交于 2020-01-14 07:59:06
问题 I am using BOTH Guzzle and Codeigniter 3.0 for the first time. Also I admit I am using php namespace for the first time. I am trying to make a very simple get request using Guzzle according to the examples provided in the docs. (The Guzzle docs say nothing about codeigniter). The Guzzle files are located at application/class/guzzle Here is my very simple controller public function indey () { $data = array(); $data['main_content'] = "hiview"; $data['title'] = "Data Analyzer - Welcome"; $data[

PHP + Guzzle, Sending Authorization Key in Header

瘦欲@ 提交于 2020-01-14 05:32:05
问题 I'm new to Guzzle and I'm attempting to generate the following REST call: https://product-search.api.cj.com/v2/product-search?website-id=1594990&keywords=%2Bsony+-camera GET /v2/product-search?website-id=1594990&keywords=%2Bsony+-camera HTTP/1.1 Host: link-search.api.cj.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding

What is the best way to use Guzzle to check if a remote file exists?

橙三吉。 提交于 2020-01-12 08:07:48
问题 I would like to use Guzzle to check if a remote file exists. This is an example of how I am currently checking: /** * @return boolean */ function exists() { // By default get_headers uses a GET request to fetch the headers. // Send a HEAD request instead stream_context_set_default( array( 'http' => array( 'method' => 'HEAD' ) ) ); // Get the file headers $file_headers = @get_headers($this->file); // Check file headers for 404 if($file_headers[0] == 'HTTP/1.1 404 Not Found') return false; //

Guzzle 6 Large file uploads / Chunking

人走茶凉 提交于 2020-01-07 04:30:54
问题 I've read that if Guzzle cannot determine Content-Length, it will send Transfer-Encoding: Chunked headers and cURL on the back-end will handling the chunking. But I'm obviously hitting post_max_size limit. ("POST Content-Length of 524288375 bytes exceeds the limit of 8388608 bytes) when POSTing to a working uploadChunkerController. I know the upload handler (endpoint) works with smaller files. I feel I have something configured wrong with my Guzzle options. I have to set verify to false and I

Guzzle add CSRF token

不打扰是莪最后的温柔 提交于 2020-01-07 03:41:22
问题 I am trying to create a product in drupal commerce using guzzle and restful webservices. When i am trying to create a new product i use the following process: 1) Login as a user who has the rights to create a product (succes) 2) Request CSRF token (succes) 3) Create product : Uh oh!: Client error response [status code] 401 [reason phrase] Unauthorized: Access to this operation not granted Now when i am doing this process trough poster (Firfox add-on). I can succesfully create a product, but

Guzzle Returning Stream? [duplicate]

徘徊边缘 提交于 2020-01-06 11:43:05
问题 This question already has answers here : Guzzlehttp - How get the body of a response from Guzzle 6? (2 answers) Closed last year . I have this: private function logSearch($term) { $geo_data = $this->geoIP($ip); dd($geo_data); } public function geoIP($ip) { $url = "http://api.ipstack.com/$ip?access_key=" . env('GEOIP_KEY'); $response = $this->client->request('GET', $url); return $response->getBody(); } The response should be: {"ip":"78.63.56.237","type":"ipv4","continent_code":"EU"...etc} But

How do I parse this json inside array data in view blade?

試著忘記壹切 提交于 2020-01-06 09:03:42
问题 Currently this is my view {{ $data["id_user"] }} my controller $client = new Client; $request = $client->get('url')->getBody()->getContents(); return view('Admin/lala')->with('data', json_decode($request, true)); get api { "code": 200, "data": [ { "id_user": 1 } ] } I wanted to display it, I've tried it like in here but it's still an error. is there something wrong when I parse the data 回答1: As in your json your id_user is inside array data so you have to use foreach in your blade. Controller

Can't get Guzzle working in my Laravel app on Bluemix

岁酱吖の 提交于 2020-01-06 04:00:08
问题 I have a working PHP app running in Bluemix that I want to extend to call a RESTful service (Insights for Twitter). Since PHP has no built-in way to call the service, I looked around and decided to use Guzzle. I downloaded Guzzle 6.0.2 from its Git and imported the zip into my httdocs/vendor path and renamed the imported path GuzzleHttp I changed my buildpack to get PHP 5.5 and updated composer.json to the Autoload.psr4 property with: "GuzzleHttp\\": "htdocs/vendor/" I redeployed my app and

How to extract individual array values from JSON response using Guzzle and Laravel

限于喜欢 提交于 2020-01-05 07:12:34
问题 I'm struggling to get data from JSON response. This is my code for getting the data: $client = new Client; $r = $client->get("http://my.api.com/get-campaign/" . $id . "?api_token=1235"); $apiResult = json_decode($r->getBody(), true); dd($apiResult); And I get something like this: array:4 [ "campaign" => array:1 [ 0 => array:3 [ "manufacturer" => "Sony" "product" => "PlayStation 4" "created_at" => "2015-07-04T00:00:00+00:00" ] ] "media" => array:2 [ "video" => "https://my.domain.com/421156.mp4