2016-08-20 6 views
0

Ich versuche, einige Informationen über PHP Curl zu bekommen. Es arbeitet völlig in Ordnung in meiner localhost wamp Umgebung, aber wenn ich es online auf meinem Server laden, heißt es: -400 Schlechte Anfrage, funktioniert gut localhost

400 Bad Request 

nginx/1.9.12 

Hier ist mein Code: -

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,"https://api.blockcypher.com/v1/eth/main/addrs?token=some_token") 
curl_setopt($ch, CURLOPT_POST, 1); 

// receive server response ... 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

$server_output = curl_exec ($ch); 
curl_close ($ch); 
var_dump($server_output); 

Antwort

0

In API-Dokumentation I don Es wird nichts angezeigt, bei dem Token eine Anfrage für eine POST-Anfrage gestellt hat.

Also, ich habe Ihren Code überprüft, aber setzte Token als Postfeld und es funktionierte:

<?php 

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,"https://api.blockcypher.com/v1/eth/main/addrs"); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, 'token=some-token-here'); 

// receive server response ... 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

$server_output = curl_exec ($ch); 
curl_close ($ch); 
var_dump($server_output); 

docs: https://dev.blockcypher.com/?javascript#generate-address-endpoint