mardi 31 octobre 2017

Guzzle Error - cURL error 6: Couldn't resolve host

Description

If I have this in my class

class CURL {

public static function get($url) {

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($ch, CURLOPT_TIMEOUT_MS, 1000);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //<------ Note HERE 
    curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
    $result = curl_exec($ch);
    curl_close($ch);
    $result =  json_decode($result, true);
    return $result;

}

My page load fine.

enter image description here


If I have this in my class

<?php
namespace App;

use Request,Auth;
use App\Log, App\Helper;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;



class CURL {

    public static function get($url) {

        $client = new Client();
        $result = $client->request('GET',$url, ['http_errors' => false, 'verify' => false ]);
        $result = (string) $result->getBody();
        $result = json_decode($result, true);
        return $result;

    }
    ...

}

As you can see, I tried set 'verify' => false already.

My page show this error.

enter image description here


Questions

How would one go about and debug this further ?


I'm open to any suggestions at this moment.

Any hints/suggestions / helps on this be will be much appreciated!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire