这是我的问题,下面我有一个 Api 脚本来手动输入 xml 对象 [user_token] 以根据令牌访问用户信息。因此,要输入数组中的每个属性,我使用了代码
foreach ($xml->result->data->users->entries->user_token as $user_token1)
echo $user_token1;
然后插入
if ($oneall_curly->get (SITE_DOMAIN . "/users/" . $user_token1 . ".xml"))
{
$result = $oneall_curly->get_result ();
print_r (($result->body));
}
因此,在此之后我不确定出了什么问题,我在堆栈溢出和 php.net 上搜索了许多答案。我当然不是专家,实际上只是编码 php 的新手,但我肯定会感谢对这个问题的一些见解或对创建变量 $user_token1 的代码的帮助
非常感谢您的关注!
SimpleXMLElement Object
(
[request] => SimpleXMLElement Object
(
[date] => Fri, 26 Jul 2013 12:18:36 +0200
[resource] => /users.xml??page=1&order_direction=desc
[status] => SimpleXMLElement Object
(
[flag] => success
[code] => 200
[info] => Your request has been processed successfully
)
)
[result] => SimpleXMLElement Object
(
[data] => SimpleXMLElement Object
(
[users] => SimpleXMLElement Object
(
[pagination] => SimpleXMLElement Object
(
[current_page] => 1
[total_pages] => 1
[entries_per_page] => 500
[total_entries] => 2
[order] => SimpleXMLElement Object
(
[field] => date_creation
[direction] => desc
)
)
[count] => 2
[entries] => Array
(
[0] => SimpleXMLElement Object
(
[user_token] => 11111111-4444-bbbb-1111-111111111111
[date_creation] => Wed, 24 Jul 2013 00:33:28 +0200
[date_last_login] => Wed, 24 Jul 2013 02:08:44 +0200
[num_logins] => 2
)
[1] => SimpleXMLElement Object
(
[user_token] => 22222222-5555-aaaa-2222-333333333333
[date_creation] => Wed, 24 Jul 2013 00:28:56 +0200
[date_last_login] => Thu, 25 Jul 2013 07:08:20 +0200
[num_logins] => 4
)
)
)
)
)
)
这是我从以前的代码中输出的 simpleXML 对象
$raw = "http://../../file.php";
$xml = simplexml_load_file($raw);
echo '<pre>';
print_r($xml);
echo '</pre>';
return $xml;
// Get an element by its id attribute
// or, loop over all of the <rate> elements
foreach ($xml->result->data->users->entries->user_token as $user_token1)
echo $user_token1;
if ($oneall_curly->get (SITE_DOMAIN . "/users/" . $user_token1 . ".xml"))
{
$result = $oneall_curly->get_result ();
print_r (($result->body));
}
//Error
else
{
$result = $oneall_curly->get_result ();
echo "Error: " . $result->http_info . "\n";
}
?>