guzzle

Using Guzzle to consume SOAP

﹥>﹥吖頭↗ 提交于 2019-12-13 11:38:38
问题 I'm loving the Guzzle framework that I just discovered. I'm using it to aggregate data across multiple API's using different response structures. It's worked find with JSON and XML, but one the services i need to consume uses SOAP. Is there a built-in way to consume SOAP services with Guzzle? 回答1: You can get Guzzle to send SOAP requests. Note that SOAP always has an Envelope, Header and Body. <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org

Laravel Guzzle getting destination and due time from a page

烈酒焚心 提交于 2019-12-13 08:27:27
问题 I want my website to scrape information from this page beta.tfgm.com/public-transport/tram/stops/oldham-central-tra‌​m and in particular I want to scrape destination and due time from that website and give me an output. At this moment my controller looks like this: function guzzle(){ $client = new \GuzzleHttp\Client(); $results = $client->get('https://beta.tfgm.com/public-transport/tram/stops/oldham-central-tram'); //$result->getBody(); //return view('hello')->with('results', $results); //dd(

How to Query Builder in json data laravel 5.1

北城余情 提交于 2019-12-13 07:19:43
问题 how to query builder in json data? i'm using guzzle , all i want how to query like searching data where amount is NOT NULL? json data results : { "amount": [ { "member_id": "SSD", "sum4": null, "sum5": null, "sum6": null }, { "member_id": "OGG", "sum4": 122, "sum5": 242, "sum6": 123 }, { "member_id": "PUCAN", "sum4": 123, "sum5": 443, "sum6": 222 }, { "member_id": "SS3TG", "sum4": null, "sum5": null, "sum6": null } ] } ALL I WANT HOW TO GET sum4,sum6,sum6 WHERE NOT NULL IN JSON RESULT, can u

Guzzle ~6 and Google Place API - error when using pagination (pagetoken)

╄→гoц情女王★ 提交于 2019-12-13 03:26:39
问题 I'm trying to get a set of universities near a couple of locations (lat/lng). To do so I'm using the Google Maps Places API Web Services and this small script in PHP with Guzzle ~6.0 . I'm using this code to fetch Google APIs: $positions = [ [51.388667, 2.557513], // <- no next_page_token [51.388667, 2.750000], // <- next_page_token ]; foreach($geo in $positions) { getJsonPlacesResponse($geo); } function getJsonPlacesResponse($geo) { $lat = $geo[0]; $lng = $geo[1]; if ($lat == 'Latitude')

Using Guzzle to send POST request with JSON

那年仲夏 提交于 2019-12-12 19:22:47
问题 $client = new Client(); $url = 'api-url'; $request = $client->post($url, [ 'headers' => ['Content-Type' => 'application/json'], 'json' => ['token' => 'foo'] ]); return $request; And I get back 502 Bad Gateway and Resource interpreted as Document but transferred with MIME type application/json I need to make a POST request with some json. How can I do that with Guzzle in Laravel? 回答1: Give it a try $response = $client->post('http://api.example.com', [ 'json' => [ 'key' => 'value' ] ]); dd(

Laravel - Get client IP address - Getting always 127.0.0.1 result

不想你离开。 提交于 2019-12-12 19:21:06
问题 I'm unable to get the IP address of the client which I need to determine his current location. I've used request->ip(), $_SERVER['REMOTE_ADDR'] and I always get a 127.0.0.1 result which is not what I want. What am I doing wrong? 回答1: request->ip() will give you client IP. You're getting 127.0.0.1 in because you're trying to access your local project from the same machine. 回答2: Sometimes your clients use your application through a proxy, so you should not depend on $_SERVER['REMOTE_ADDR'].

Specify raw body of a POST request with Guzzle

放肆的年华 提交于 2019-12-12 04:04:55
问题 With Guzzle (version 3), I'd like to specify the body of a POST request in "raw" mode. I'm currently trying this: $guzzleRequest = $client->createRequest( 'POST', $uri, null, 'un=one&deux=two' ); But it kind of doesn't work. If I dump my $guzzleRequest I can see that postFields->data is empty. Using $guzzleRequest->setBody() afterwards doesn't help. However if I specify the body as ['un'=>'one', 'deux'=>'two'] , it works as expected. How can I specify the body of the request as 'un=one&deux

Where to store access and refresh token from external web API in Symfony2?

淺唱寂寞╮ 提交于 2019-12-12 02:16:54
问题 I have created a simple Symfony2 project which allows employees to log in and check news and other stuff. Then I wanted to integrate an external system that shows whether the employee is at work or not. I have no control over the other system but I got an web API (REST) so that I may retrieve the information needed. I decided to use GuzzleBundle as the PHP HTTP Client to get the information I need because of the answers in this post (stackoverflow). So I logged in which is required by the web

Amazon AWS PHP SDK with Guzzle's MultiCurl?

佐手、 提交于 2019-12-12 01:14:54
问题 I need to perform some fairly heavy queries with Amazon's AWS SDK for PHP. The most efficient way would be to use PHP's MultiCurl. It seems that Guzzle already has functionality for MultiCurl built in. Does using the standard methods provided by the AWS SDK automatically use MultiCurl or do I have to specify it's usage directly? E.g. calling $sns->Publish() 30 times. Thanks! 回答1: Parallel requests work exactly the same in the SDK as in plain Guzzle and do take advantage of MultiCurl. For

Allowed memory size of 134217728 bytes exhausted (tried to allocate 31989760 bytes) In a do…while loop

≡放荡痞女 提交于 2019-12-11 23:55:22
问题 I have a do while code that reaches to an API to get data from AWS Elastic search. When I increase size, I get memory error. Now I have reduced size to 20, but want to loop through the results as a cronjob yet, it fails. I have increased memory to 4096 yet, it fails I have increased memory limit in my .ini file, yet it fails. Since its a cronjob, I have no idea how to use scroll. do { $transporter = new TransporterController; $response = $transporter->dispatchSearch($paper->title, '55%',