【发布时间】:2017-10-05 23:53:05
【问题描述】:
我有一个第三方数据库,我通过他们的 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 新手,无法打印数据。我正在尝试打印每条记录中的选择字段(即电子邮件、姓氏、名字、电话)。
我将不胜感激。
保重, 比尔
【问题讨论】:
-
Stack Overflow 您应该尝试自己编写代码。在 doing more research 之后,如果您有问题,您可以发布您尝试过的内容,并清楚地解释什么不起作用并提供Minimal, Complete, and Verifiable example。我建议阅读How to Ask 一个好问题和the perfect question。另外,请务必使用tour 并阅读this。
-
欢迎来到 StackOverflow!到目前为止,您尝试过什么吗? StackOverflow 不是免费的代码编写服务,希望您能try to solve your own problem first。请更新您的问题以显示您已经尝试过的内容,并在minimal, complete, and verifiable example 中展示您面临的具体问题。如需更多信息,请参阅how to ask good questions,并拨打tour of the site :)