Advertisement
Guest User

Untitled

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