-1

https://satoshidice.com/api/statusで実行しようとしていますが、これが返されますfile_get_contents()- http://puu.sh/58lCb

print file_get_contents($this->base . 'status');

$this->basesatoshidice.com/api(httpあり)です。

上記の画像にあるものを返すのはなぜですか..?

4

1 に答える 1

6

file_get_contents の代わりに cURL を使用することをお勧めします

$_curl = curl_init();
curl_setopt($_curl, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($_curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($_curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($_curl, CURLOPT_COOKIEFILE, './cookiePath.txt');
curl_setopt($_curl, CURLOPT_COOKIEJAR, './cookiePath.txt');
curl_setopt($_curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; InfoPath.1)');
curl_setopt($_curl, CURLOPT_FOLLOWLOCATION, true); //new added
curl_setopt($_curl, CURLOPT_URL, $url);
$rtn = curl_exec( $_curl );

更新: 「CURLOPT_FOLLOWLOCATION」を追加

説明:

このホストでは、Cookie が存在するかどうかを確認します。

要求された Cookie が存在しない場合、Cookie を作成し、リダイレクトする HTTP コード 307 を生成します。

https://satoshidice.com/api/status?stage=1

于 2013-11-04T06:23:03.540 に答える