我有一个第三方数据库,我已经通过他们的API下载了它。这是我的代码:
<?php
include_once('./rmapi.class.php');
# initilize class
$rmapi = new RMAPI('mySecretToken');
#request AccountID
$account_info = $rmapi->rm_administrationUsersCurrent();
#parse array and access the account id stdClass object value. returns just the the account GUID as a string
$accountId = $account_info['service_response']->AccountId;
$listId = "mySecretId";
$request = json_decode("{}");
$reportSummary=$rmapi->rm_listsRecipientsFiltered($accountId, $listId, $request);
$data=$reportSummary['service_response'];
$records = count($data);
for ($i = 0; $i < $records; $i++) {
echo "<br />";
echo $i." ";
echo $data[$i]->Email;
echo $data[$i]->lastname;
}
echo "<br />";
?>
以下是我认为的第一张唱片:
array(4) { [0]=> object(stdClass)#4 (8) { ["BounceDate"]=> string(20) "0001-01-01T05:00:00Z" ["BounceStatus"]=> string(4) "None" ["CreateDate"]=> string(23) "2017-10-02T14:00:10.41Z" ["Email"]=> string(26) "test@test.com" ["EmailFormatPreference"]=> string(11) "TextAndHtml" ["OptOut"]=> bool(false) ["OptOutDate"]=> string(20) "0001-01-01T05:00:00Z" ["Properties"]=> array(13) { [0]=> object(stdClass)#5 (2) { ["Name"]=> string(5) "email" ["Value"]=> string(26) "test@test.co" } [1]=> object(stdClass)#6 (2) { ["Name"]=> string(9) "firstname" ["Value"]=> string(1) "first" } [2]=> object(stdClass)#7 (2) { ["Name"]=> string(8) "lastname" ["Value"]=> string(1) "last" } [3]=> object(stdClass)#8 (2) { ["Name"]=> string(7) "address" ["Value"]=> string(1) "123 main" } [4]=> object(stdClass)#9 (2) { ["Name"]=> string(4) "city" ["Value"]=> string(1) "anytown" } [5]=> object(stdClass)#10 (2) { ["Name"]=> string(5) "state" ["Value"]=> string(1) "anystate" } [6]=> object(stdClass)#11 (2) { ["Name"]=> string(3) "zip" ["Value"]=> string(1) "00000" } [7]=> object(stdClass)#12 (2) { ["Name"]=> string(5) "phone" ["Value"]=> string(1) "123-456-7890" } [8]=> object(stdClass)#13 (2) { ["Name"]=> string(8) "birthday" ["Value"]=> string(1) "01/01/01" } [9]=> object(stdClass)#14 (2) { ["Name"]=> string(11) "kr_comments" ["Value"]=> string(1) "test comment" } [10]=> object(stdClass)#15 (2) { ["Name"]=> string(10) "lastopened" ["Value"]=> string(21) "10/3/2017 11:41:22 AM" } [11]=> object(stdClass)#16 (2) { ["Name"]=> string(11) "lastclicked" ["Value"]=> string(0) "" } [12]=> object(stdClass)#17 (2) { ["Name"]=> string(10) "createdate" ["Value"]=> string(21) "10/2/2017 10:00:10 AM" } } }
我是PHP的新手,我无法打印数据。我正在尝试打印每个记录中的选择字段(即电子邮件,姓氏,名字,电话)。
我将不胜感激。
保重, 比尔
答案 0 :(得分:0)
在for循环中,您没有$记录的值。你需要:
$records = count($data);