I am using the icontact php api. I want to get the last contact who entered the list so in the icontact api php I have this:
<php
public function getContacts() {
// Make the call and return the data
return $this->makeCall("/a/{$this->setAccountId()} /c/{$this->setClientFolderId()}/contacts?listId=49626&status=total&createDate=2015-02-16&createDateSearchType=gt", 'GET');
}
?>
than I use this to call it:
<?php
$oiContact = iContactApi::getInstance();
try {
var_dump($oiContact->getContacts());
} catch (Exception $oException) { // Catch any exceptions
var_dump($oiContact->getErrors());
}
$obj = $oiContact->getLastResponse();
$data = json_decode($obj,TRUE);
echo $data['contacts'][0]['email'];
echo $data['contacts'][0]['commitmentscore'];
echo $data['contacts'][0]['firstName'];
echo $data['contacts'][0]['phone'];
?>
It keeps giving me the same contact it is because the 0 in the echo but how can I make that a variable or an if condition just not sure how
paste bins with full code
http://pastebin.com/SBf73UNb //call
http://pastebin.com/CuGcCvU1 //api
I think you can use orderby option,
check this link
sample they used
Instead of
firstname
you can use date, something like normalSQL
query doing then fetch only first contact.Also the return data will be always array so you have to run within a
foreach
for iterate the data.Hope it helps.