Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. <?php
  2. $host = "localhost";
  3. $user = "borneope_jon123";
  4. $pass = "jon1234509876";
  5. $db = "borneope_jon123";
  6. $konek = mysql_connect($host, $user, $pass) or die ('Koneksii Gagal! ');
  7. mysql_select_db($db);
  8. ?>
  9. <?
  10.  
  11.  
  12. $result = mysql_query("SELECT * FROM history_socmed WHERE status != 'Completed' AND provider = 'BORNEO' ORDER BY id ASC");
  13. while($row = mysql_fetch_array($result))
  14. {
  15. $statusnya = $row['status'];
  16. $id_order = $row['id_order'];
  17. $nomer = $row['no'];
  18.  
  19. class Api
  20. {
  21. public $api_url = 'https://sosmedpedia.com/api.php'; // API URL
  22.  
  23. public $api_key = 'SOSPED-289739fbf6a4f054e3bf330b0cdecb04'; // Your API key
  24.  
  25. public function status($order_id) { // Get status, remains
  26. return json_decode($this->connect(array(
  27. 'api' => $this->api_key,
  28. 'action' => 'cekin',
  29. 'id' => $order_id
  30. )));
  31. }
  32.  
  33.  
  34. private function connect($post) {
  35. $_post = Array();
  36. if (is_array($post)) {
  37. foreach ($post as $name => $value) {
  38. $_post[] = $name.'='.urlencode($value);
  39. }
  40. }
  41. $ch = curl_init($this->api_url);
  42. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  43. curl_setopt($ch, CURLOPT_POST, 1);
  44. curl_setopt($ch, CURLOPT_HEADER, 0);
  45. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  46. if (is_array($post)) {
  47. curl_setopt($ch, CURLOPT_POSTFIELDS, join('&', $_post));
  48. }
  49. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
  50. $result = curl_exec($ch);
  51. echo $result;
  52. if (curl_errno($ch) != 0 && empty($result)) {
  53. $result = false;
  54. }
  55. curl_close($ch);
  56. return $result;
  57. }
  58. }
  59.  
  60. // Examples
  61. $api = new Api();
  62. $status = $api->status($id_order);
  63. $check = $status->datanya->status;
  64.  
  65. if($check == '4'){
  66. $provice = 'Canceled';
  67. $save = mysql_query("UPDATE history_socmed SET status = '$provice' WHERE id_order = '$id_order'");
  68. if($save){
  69. echo 'Sukses Update '.$id_order.' Link : '.$status->data->link;
  70. }
  71. } else if($check == '2'){
  72. $provice = 'Completed';
  73. $save = mysql_query("UPDATE history_socmed SET status = '$provice' WHERE id_order = '$id_order'");
  74. if($save){
  75. echo 'Sukses Update '.$id_order.' Link : '.$status->data->link;
  76. }
  77. } else {
  78. $provice = $check;
  79. $save = mysql_query("UPDATE history_socmed SET status = '$provice' WHERE id_order = '$id_order'");
  80. if($save){
  81. echo 'Sukses Update '.$id_order.' Link : '.$status->data->link.' Stausnya '.$statusnya;
  82. }
  83. }
  84.  
  85.  
  86. }
  87. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement