0

有人可以帮我解决这个问题。我对 google-api 调用的返回结果有疑问

我想将它们作为 html 回显,但 Firefox 一直显示提要页面。

在 IE 中,我收到一条错误消息,指出 xml 文档只能包含一个必须是原子“feed”元素的顶级元素,所以我不明白。

我能做些什么来改善这一点?

$response= curl_exec($ch);

curl_close($ch);

// Parse the response
$response= simplexml_load_string($response);

foreach($response->entry as $position)
{
    echo "position: " . $position->title . "<br />";
    //next would be the stockvalue, but I don't yet know how to get that

}

编辑

$headers = array(
    "Authorization: GoogleLogin auth=" . $auth,
    "GData-Version: 2",
);

 $ch=curl_init(); 
curl_setopt($ch, CURLOPT_URL, "http://finance.google.com/finance/feeds/default/portfolios/1/positions");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

编辑 我看到了我没有使用的错误

curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

谢谢,理查德

4

1 回答 1

1

试试var_dump()你的$response,看看你里面有什么数据。

我将使用file_get_contents()而不是CURL.

于 2009-12-28T22:07:23.730 回答