CC_List

Class that is used for retrieving all the Email Lists from Constant Contact and all Registered Email Addresses.

Defined (1)

The class is defined in the following location(s).

/api/cc_class.php  
  1. class CC_List extends CC_Utility { 
  2.  
  3. /** 
  4. * Recursive Method that retrieves all the Email Lists from ConstantContact. 
  5. * @param string $path [default is empty] 
  6. * @return array of lists 
  7. */ 
  8. public function getLists($path = '') { 
  9. $mailLists = array(); 
  10.  
  11. if ( empty($path)) { 
  12. $call = $this->apiPath.'/lists'; 
  13. } else { 
  14. $call = $path; 
  15.  
  16. $return = $this->doServerCall($call); 
  17. $parsedReturn = simplexml_load_string($return); 
  18. $call2 = ''; 
  19.  
  20. if(empty($parsedReturn) || !(is_object($parsedReturn) || is_array($parsedReturn))) { return false; } 
  21.  
  22. foreach ($parsedReturn->link as $item) { 
  23. $tmp = $item->Attributes(); 
  24. $nextUrl = ''; 
  25. if ((string) $tmp->rel == 'next') { 
  26. $nextUrl = (string) $tmp->href; 
  27. $arrTmp = explode($this->login, $nextUrl); 
  28. $nextUrl = $arrTmp[1]; 
  29. $call2 = $this->apiPath.$nextUrl; 
  30. break; 
  31.  
  32. foreach ($parsedReturn->entry as $item) { 
  33. if ($this->contact_lists ) { 
  34. if (in_array((string) $item->title, $this->contact_lists)) { 
  35. $tmp = array(); 
  36. $tmp['id'] = (string) $item->id; 
  37. $tmp['title'] = (string) $item->title; 
  38. $mailLists[] = $tmp; 
  39. } else if (!in_array((string) $item->title, $this->doNotIncludeLists)) { 
  40. $tmp = array(); 
  41. $tmp['id'] = (string) $item->id; 
  42. $tmp['title'] = (string) $item->title; 
  43. $mailLists[] = $tmp; 
  44.  
  45. if ( empty($call2)) { 
  46. return $mailLists; 
  47. } else { 
  48. return array_merge($mailLists, $this->getLists($call2)); 
  49.  
  50.  
  51. /** 
  52. * Method that retrieves all Registered Email Addresses. 
  53. * @param string $email_id [default is empty] 
  54. * @return array of lists 
  55. */ 
  56. public function getAccountLists($email_id = '') { 
  57. $mailAccountList = array(); 
  58.  
  59. if ( empty($email_id)) { 
  60. $call = $this->apiPath.'/settings/emailaddresses'; 
  61. } else { 
  62. $call = $this->apiPath.'/settings/emailaddresses/'.$email_id; 
  63.  
  64. $return = $this->doServerCall($call); 
  65. $parsedReturn = simplexml_load_string($return); 
  66.  
  67. foreach ($parsedReturn->entry as $item) { 
  68. $nextStatus = $item->content->Email->Status; 
  69. $nextEmail = (string) $item->title; 
  70. $nextId = $item->id; 
  71. $nextAccountList = array('Email'=>$nextEmail, 'Id'=>$nextId); 
  72. /** 
  73. * Removed to fix this issue: 
  74. * http://wordpress.org/support/topic/login-problem-fix?replies=2 
  75. */ 
  76. #if($nextStatus == 'Verified') { 
  77. $mailAccountList[] = $nextAccountList; 
  78. #} 
  79. return $mailAccountList; 
  80.