Advertisement
Guest User

Untitled

a guest
May 29th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. public function addBooKurier() {
  2.  
  3. $booKurierAPI = 'http://www.bookurier.ro/colete/serv/add_cmd.php';
  4.  
  5. $xmlkeys = array('client' => 'id_client', 'unq' => 'cod_unic', 'recv' => 'nume_client', 'phone' => 'telefon_client', 'email' => 'email_client', 'country' => 'tara_client', 'city' => 'oras_client', 'zip' => 'cod_postal', 'district' => 'sector', 'street' => 'strada', 'no' => 'numar_strada', 'bl' => 'bloc', 'ent' => 'scara', 'floor' => 'etaj', 'apt' => 'apartament', 'interphone' => 'interfon', 'service' => 'cod_serviciu', 'packs' => 'nr_cutii', 'exchange_pack' => 'colet_la_schimb', 'weight' => 'greutate', 'rbs_val' => 'val_ramburs', 'insurance_val' => 'val_asigurare', 'notes' => 'observatii');
  6. $xml = '';
  7.  
  8. foreach ($xmlkeys as $xmlkey => $postkey) {
  9. $value = (isset($this->request->post[$postkey])) ? $this->request->post[$postkey] : '';
  10. $xml .= "<${xmlkey}>" . htmlentities($value, ENT_QUOTES) . "</${xmlkey}>\n";
  11. }
  12.  
  13. $msg = "<msg><cmd>${xml}</cmd></msg>";
  14.  
  15. $data = array(
  16. 'userid' => urlencode($this->username_bookurier),
  17. 'pwd' => urlencode($this->password_bookurier),
  18. 'msg' => $msg
  19. );
  20.  
  21. $postdata = http_build_query($data);
  22.  
  23. $ch = curl_init();
  24.  
  25. curl_setopt($ch, CURLOPT_URL, $booKurierAPI);
  26. curl_setopt($ch, CURLOPT_POST, 1);
  27. curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  28. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  29.  
  30. $result = curl_exec($ch);
  31.  
  32. curl_close($ch);
  33.  
  34. file_put_contents('result.txt', $result);
  35.  
  36. return $result;
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement