PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/esendex-devel/Examples/EsendexContactServiceExample.php

https://github.com/fayazv/Taarifa_Web
PHP | 211 lines | 110 code | 61 blank | 40 comment | 0 complexity | 81e438eb90ba5fd025ef0c096fa9198d MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-3.0, BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /*
  3. Name: EsendexContactServiceExample.php
  4. Description: Example usage for the EsendexContactService class
  5. Documentation:
  6. Copyright Š 2007 Esendex
  7. If you have any questions or comments, please contact:
  8. support@esendex.com
  9. http://www.esendex.com/support
  10. Esendex
  11. http://www.esendex.com
  12. */
  13. include_once( "../EsendexContactService.php" );
  14. // Test Variables - assign values accordingly:
  15. $username = ""; // Your Username (normally an email address).
  16. $password = ""; // Your Password.
  17. $accountReference = ""; // Your Account Reference (either your virtual mobile number, or EX account number).
  18. $result; // The result of a service request.
  19. $contactID = array(); // A contact ID (GUID).
  20. $contactName = ""; // A contact name.
  21. $mobileNumber = ""; // A mobile number.
  22. $groupID; // A group ID (GUID).
  23. $groupName = "myGroup"; // A group name.
  24. $groupMembers = array(); // An array of group members.
  25. $contactService = new EsendexContactService( $username, $password, $accountReference );
  26. // **********
  27. // Add a contact with the minimum details.
  28. print "<b>AddContact</b><br />";
  29. $result = $contactService->AddContact( $contactName, $mobileNumber );
  30. print_r( $result );
  31. print "<br />";
  32. // Extract the contact ID from the result.
  33. $contactID = $result['ContactID'];
  34. print "<b>Contact ID</b>: $contactID";
  35. print "<br /><br /><hr /><br />";
  36. // *********
  37. // Get all of the information for a contact.
  38. print "<b>GetContact</b><br />";
  39. $result = $contactService->GetContact( $contactID );
  40. print_r( $result );
  41. print "<br /><br />";
  42. $contacts = $result['Messages'];
  43. foreach ( $contacts as $contact )
  44. {
  45. foreach ( $contact as $key => $value )
  46. {
  47. print "<b>$key</b>: $value<br />";
  48. }
  49. print "<br />";
  50. }
  51. print "<hr /><br />";
  52. // *********
  53. // Update a contact with minimum details.
  54. print "<b>UpdateContact</b><br />";
  55. print_r( $contactService->UpdateContact( $contactID, "myOtherContact", "9876543210" ) );
  56. print "<br /><br /><hr /><br />";
  57. // *********
  58. // Get all of the contacts by not specifying a contact ID.
  59. print "<b>GetContact</b><br />";
  60. $result = $contactService->GetContact();
  61. print_r( $result );
  62. print "<br /><br />";
  63. $contacts = $result['Messages'];
  64. foreach ( $contacts as $contact )
  65. {
  66. foreach ( $contact as $key => $value )
  67. {
  68. print "<b>$key</b>: $value<br />";
  69. }
  70. print "<br />";
  71. }
  72. print "<hr /><br />";
  73. // *********
  74. // Add a group with the minimum details.
  75. print "<b>AddGroup</b><br />";
  76. $result = $contactService->AddGroup( $groupName );
  77. print_r( $result );
  78. print "<br />";
  79. // Extract the group ID from the result.
  80. $groupID = $result['GroupID'];
  81. print "<b>Group ID</b>: $groupID";
  82. print "<br /><br /><hr /><br />";
  83. // *********
  84. // Get all of the information for a group.
  85. print "<b>GetGroup</b><br />";
  86. $result = $contactService->GetGroup( $groupID );
  87. print_r( $result );
  88. print "<br /><br />";
  89. $groups = $result['Messages'];
  90. foreach ( $groups as $group )
  91. {
  92. foreach ( $group as $key => $value )
  93. {
  94. print "<b>$key</b>: $value<br />";
  95. }
  96. print "<br />";
  97. }
  98. print "<hr /><br />";
  99. // *********
  100. // Update a group with a new name, description and contact member IDs.
  101. print "<b>UpdateGroup</b><br />";
  102. print_r( $contactService->UpdateGroup( $groupID, "myOtherGroup", "myDescription", $contactID ) );
  103. print "<br /><br /><hr /><br />";
  104. // *********
  105. // Get all of the groups by not specifying a group ID.
  106. print "<b>GetGroup</b><br />";
  107. $result = $contactService->GetGroup();
  108. print_r( $result );
  109. print "<br /><br />";
  110. $groups = $result['Messages'];
  111. foreach ( $groups as $group )
  112. {
  113. foreach ( $group as $key => $value )
  114. {
  115. print "<b>$key</b>: $value<br />";
  116. }
  117. print "<br />";
  118. }
  119. print "<hr /><br />";
  120. // *********
  121. // Get all of the contacts associated with a group.
  122. print "<b>GetGroupMembers</b><br />";
  123. $result = $contactService->GetGroupMembers( $groupID );
  124. print_r( $result );
  125. $groupMembers = array();
  126. $groupMembers = $result['Messages'];
  127. print "<br /><br />";
  128. foreach ( $groupMembers as $groupMember )
  129. {
  130. foreach ( $groupMember as $key => $value )
  131. {
  132. print "<b>$key</b>: $value<br />";
  133. }
  134. print "<br />";
  135. }
  136. print "<hr /><br />";
  137. // *********
  138. // Delete a contact.
  139. print "<b>DeleteContact</b><br />";
  140. print_r( $contactService->DeleteContact( $contactID ) );
  141. print "<br /><br /><hr /><br />";
  142. // *********
  143. // Delete a group.
  144. print "<b>DeleteGroup</b><br />";
  145. print_r( $contactService->DeleteGroup( $groupID ) );
  146. ?>