ブラウザーにhttp://rest.example.com/account/get-balance/27e3xxx/7vvU4c95trfxxxx
入力して Enter キーを押すと、次の XML 応答が返されます。
<?xml version = "1.0" encoding = "UTF-8" standalone = "yes" ?>
<accountBalance>
<creditLimit>0.0</creditLimit>
<quotaEnabled>true</quotaEnabled>
<value>2.0</value>
</accountBalance>
しかし、PHP 内で同じ URL を試していると、応答 Page not found (おっと! That page does not exist. ) が送信されます。ここに私が試すいくつかの方法があります...
SimpleXML の使用
$content = simplexml_load_file($this->request_uri);
ファイル メソッドの使用
$content = file_get_contents($this->request_uri);
CURL の使用
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $this->request_uri);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
$content = curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
$this->request_uri
=ブラウザに貼り付けた同じURL。どこが間違っていますか?これについて私を助けてください。ありがとうございました。