Guest User

api

a guest
Mar 5th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. //api.php
  2.  
  3. <?php
  4.  
  5. require_once("dbcontroller.php");
  6. $db_handle = new DBController();
  7.  
  8. $curl_data['username']='admin';
  9. $curl_data['password']='admin123';
  10.  
  11.  
  12. $data = json_decode(stripslashes($_POST['data']));
  13. $response = array();
  14.  
  15. foreach($data as $id){
  16.  
  17. $orderid = $id;
  18. $curl_data['awb']=$orderid;
  19.  
  20. $hide = '';
  21. $url = 'https://plapi.ecomexpress.in/track_me/api/mawbd/?awb=awbnumber&order='.$orderid.'&username=admin&password=admin123';
  22. $ch = curl_init();
  23. $ch = curl_init();
  24. curl_setopt($ch, CURLOPT_URL,$url);
  25. curl_setopt($ch, CURLOPT_POST, true);
  26. curl_setopt($ch, CURLOPT_POSTFIELDS, $curl_data);
  27. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  28.  
  29.  
  30. $output = curl_exec ($ch);
  31. curl_close($ch);
  32. $res = explode("\n",$output);
  33.  
  34. if ( ! isset($res[13]))
  35. {
  36. $res[13] = null;
  37. }
  38.  
  39.  
  40.  
  41. $status = str_replace('</field>','',$res[13]);
  42.  
  43.  
  44.  
  45. $statusfinal = str_replace('<field type="CharField" name="status">','',$status);
  46. if($statusfinal!='')
  47. {
  48. $sqlecom = "UPDATE do_order set in_transit='".$statusfinal."',tconformed_by='Ecom' where order_id=".$orderid;
  49. $db_handleecom = new DBController();
  50. $resultecom = $db_handleecom->executeUpdate($sqlecom);
  51. }
  52.  
  53. // store the responce in array
  54.  
  55.  
  56. $response[$orderid] = $statusfinal;
  57.  
  58. }
  59. echo json_encode($response);
  60.  
  61. //return $response;
  62.  
  63. ?>
Add Comment
Please, Sign In to add comment