我正在使用活动监视器 API 并访问活动摘要。到目前为止,我有以下工作:
require_once '../../csrest_campaigns.php';
$auth = array('api_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxx');
$wrap = new CS_REST_Campaigns('xxxxxxxxxxxxxxxxxxxxxx', $auth);
$result = $wrap->get_summary();
echo "Result of GET /api/v3/campaigns/{id}/summary\n<br />";
if($result->was_successful()) {
var_dump($result->response);
} else {
echo 'Failed with code '.$result->http_status_code."\n<br /><pre>";
var_dump($result->response);
}
echo '</pre>';
我想从上面提取某些数据,所以我添加了以下内容(替换 var_dump):
foreach($result->response as $entry) {
echo $entry->Recipients;
echo $entry->TotalOpened.'<br/>';
echo $entry->Clicks.'<br/>';
echo $entry->Unsubscribed.'<br/>';
echo $entry->Bounced.'<br/>';
echo $entry->UniqueOpened.'<br/>';
echo $entry->SpamComplaints.'<br/>';
echo $entry->WebVersionURL.'<br/>';
echo $entry->WebVersionTextURL.'<br/>';
echo $entry->WorldviewURL.'<br/>';
echo $entry->Forwards.'<br/>';
echo $entry->Likes.'<br/>';
echo $entry->Mentions.'<br/>';
}
这根本没有数据显示?谁能看到我哪里出错了?
var_dump:
stdClass Object
(
[Recipients] => 5
[TotalOpened] => 28
[Clicks] => 2
[Unsubscribed] => 0
[Bounced] => 0
[UniqueOpened] => 4
[SpamComplaints] => 0
[WebVersionURL] => http://xxxxxxxxxxxxxxxx
[WebVersionTextURL] => http://xxxxxxxxxxxxxxxxxxx
[WorldviewURL] => http://xxxxxxxxxxxxxxxxxxx
[Forwards] => 0
[Likes] => 0
[Mentions] => 0
)