mailget_curl

The ColorWay mailget curl class.

Defined (1)

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

/functions/mailget_curl.php  
  1. class mailget_curl { 
  2.  
  3. function mailget_curl($mailget_api) { 
  4. global $mailget_user; 
  5. $url = "http://www.formget.com/mailget/mailget_api/user_validation"; 
  6. $data = array( 
  7. 'api_key' => $mailget_api 
  8. ); 
  9. $result = $this->curl_call($url, $data); 
  10. $result = json_decode($result); 
  11. if (empty($result)) { 
  12. $mailget_user = 'Invalid API Key'; 
  13. } elseif ($result->status == 'success') { 
  14. $mailget_user = $result->api_key; 
  15. } else { 
  16. $mailget_user = 'Invalid API Key'; 
  17.  
  18. function mailget_select_list($mailget_api) { 
  19. global $mailget_user; 
  20. $url = "http://www.formget.com/mailget/mailget_api/get_select_list"; 
  21. $data = array( 
  22. 'api_key' => $mailget_api 
  23. ); 
  24.  
  25. $result = $this->curl_call($url, $data); 
  26. $result = json_decode($result); 
  27. if ($result->status == 'success') { 
  28. $mailget_select = $result->select; 
  29. } else { 
  30. $mailget_select = 'Invalid API Key.'; 
  31. return $mailget_select; 
  32.  
  33. function get_list_in_json($mailget_api) { 
  34. global $mailget_user; 
  35. $url = "http://www.formget.com/mailget/mailget_api/get_list_in_json"; 
  36. $data = array( 
  37. 'api_key' => $mailget_api 
  38. ); 
  39.  
  40. $result = $this->curl_call($url, $data); 
  41. $result = json_decode($result); 
  42. if (empty($result)) { 
  43. $mailget_select = 'Invalid API Key'; 
  44. } elseif ($result->status == 'success') { 
  45. $mailget_select = $result->contact_list; 
  46. } else { 
  47. $mailget_select = 'Invalid API Key'; 
  48. return $mailget_select; 
  49.  
  50. /** fUNCTION CURL Data */ 
  51.  
  52. public function curl_data($arr, $list_id, $send_val = 'multiple') { 
  53. global $mailget_user; 
  54. $main_contact_arr = array(); 
  55. if ($mailget_user != 'Invalid API Key') { 
  56. if (!empty($arr)) { 
  57. $url = "http://www.formget.com/mailget/mailget_api/save_data"; 
  58. foreach ($arr as $arr_row) { 
  59. if (isset($arr_row['name']) && isset($arr_row['email']) && isset($arr_row['get_date']) && isset($arr_row['ip']) && filter_var(trim($arr_row['email']), FILTER_VALIDATE_EMAIL)) { 
  60. $contact_arr['name'] = $arr_row['name']; 
  61. $contact_arr['email'] = $arr_row['email']; 
  62. $contact_arr['date'] = $arr_row['get_date']; 
  63. $contact_arr['ip'] = $arr_row['ip']; 
  64. $main_contact_arr[$arr_row['email']] = $contact_arr; 
  65. if (!empty($main_contact_arr)) { 
  66. $main_data = json_encode($main_contact_arr); 
  67. $data = array( 
  68. 'json_arr' => $main_data,  
  69. 'list_id_enc' => $list_id,  
  70. 'send_val' => $send_val 
  71. ); 
  72.  
  73. $result = $this->curl_call($url, $data); 
  74. return $result; 
  75. } else { 
  76. return 'Invalid API Key'; 
  77.  
  78. /** fUNCTION TO CALL cURL */ 
  79.  
  80. public function curl_call($url, $data) { 
  81. $args = array( 
  82. 'method' => 'POST',  
  83. 'timeout' => 45,  
  84. 'redirection' => 5,  
  85. 'httpversion' => '1.0',  
  86. 'body' => $data,  
  87. 'cookies' => array() 
  88. ); 
  89. $result = wp_remote_post($url, $args); 
  90. $message = wp_remote_retrieve_body($result); 
  91. return $message; 
  92.