コード内に新しい PHP HTTP リクエストを作成する必要があります。json でエンコードされたデータの配列を返します。新しい HTTP リクエストを作成し、その場所にリダイレクトしないようにするにはどうすればよいですか?
ありがとう。
コード内に新しい PHP HTTP リクエストを作成する必要があります。json でエンコードされたデータの配列を返します。新しい HTTP リクエストを作成し、その場所にリダイレクトしないようにするにはどうすればよいですか?
ありがとう。
これはあなたが探しているものです: http://codular.com/curl-with-php
// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://stackoverflow.com'
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
//For testing only
print_r('<pre>');
print_r($resp);die();
json ファイルを取得して配列に入れようとしているとします。
$content = file_get_contents('http://www.example.com/test.json');
$json_array = json_decode($content);
print_r($json_array)