0

Guzzle version(s) affected: 6.3 Laravel: 5.6.3 PHP: 7.2.10

Description If I am trying to get response in tinker

$client = new \GuzzleHttp\Client();
$response = $client->get($url);
json_decode($response->getBody())

I am getting response as expected.

but in my controller

$object_res = $client->get($url);

I am getting error

"cURL error 3: malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)",…}

Which means, the url is incorrect, but as I have described, this working perfectly in tinker.

Note I am getting everything working perfectly in my localhost, this is occurring only on my test server.

Please let me know, if I need to give additional information.

Prafulla Kumar Sahu
  • 9,321
  • 11
  • 68
  • 105

3 Answers3

0

Tinker uses a different runtime than your application, this could be causing an issue because in one scenario. php goes directly from your box to the api server and in the other it goes through your webserver before making the request.

The first thing to do would be to clear your laravel cache and config with

 php artisan cache:clear

and

php artisan config:clear 

if that fails I would look into the cross-domain restrictions or settings on your web server.

dvl333
  • 183
  • 1
  • 12
0

Please check for Guzzle requirements on your server. specially

To use the PHP stream handler, allow_url_fopen must be enabled in your system's php.ini.
guttume
  • 278
  • 1
  • 7
0

I just ran into this problem on my testing server, I found it using cockpit. but my problem was with alouy/youtube. check selinux if you have that on your production server. check file permission of .env too. Hard to give a solution when the variables of your server are not presented. also Read your laravel logs, that presented the solution to me. hope this helps.

deadcow
  • 1
  • 8