Nirali Joshi
Nirali Joshi

Reputation: 2008

get response from GET request to API

I am trying to get response from api call,

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://fm.transfer-to.com/cgi-bin/shop/topup');
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
$response = curl_exec($curl);
echo $response;
$status = curl_getinfo($curl);

curl_close($curl);

// above code outputs nothing

I tried file_get_contents() , but

$url ="https://fm.transfer-to.com/cgi-bin/shop/topup";
$responses = split("\n", file_get_contents($url));
foreach ($responses as $response) {
    $key = split("=", $response)[0];
    $value= split("=", $response)[1];
    if($key != "" && $value != "") {
        $data[$key] = $value;
    }
}

It fails : failed to open stream: Connection timed out.

How to get response from Api (API sends back plain text , not json) , When i request to above URL using form.

Upvotes: 1

Views: 1235

Answers (1)

Jigar Joshi
Jigar Joshi

Reputation: 240966

This server on https has only TLSv1 support and very limited and weak ciphers support only, I believe your PHP libraries are not negotiating over this configuration

to workaround this

  • either make your PHP client support the stuff that these server supports (not recommended but only way if this server cannot update its configuration)
  • go over http (not recommended) for sandbox purpose only

See

Upvotes: 1

Related Questions