madrahimov

Untitled

Jan 19th, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. <?
  2. class Bantikov
  3. {
  4. public $login = "farmclub"; //"test_api_client"
  5. public $password = "VqKiJ5xVsQm754SjWzRr"; //"u5h7kpnsePexpjhPfc4A"
  6. public $session = false;
  7.  
  8. public function cURL($url, $cookie, $p, $token){
  9. $ch = curl_init();
  10. curl_setopt($ch, CURLOPT_URL, $url);
  11. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  12. curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  13. curl_setopt($ch, CURLOPT_REFERER, 'http://'.$_SERVER["SERVER_NAME"].'/');
  14. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  15. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  16. if($token)curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'X-Authorization: '.$token));
  17. if ($p) {
  18. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  19. curl_setopt($ch, CURLOPT_POST, 1);
  20. curl_setopt($ch, CURLOPT_POSTFIELDS, $p);
  21. }
  22. $result = curl_exec($ch);
  23. $info = curl_getinfo($ch);
  24. curl_close($ch);
  25. if ($result){
  26. return array("RESULT" => $result, "HEADERS" => $info);
  27. }else{
  28. return '';
  29. }
  30. }
  31.  
  32. public function gen_uuid() {
  33. return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  34. // 32 bits for "time_low"
  35. mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
  36.  
  37. // 16 bits for "time_mid"
  38. mt_rand( 0, 0xffff ),
  39.  
  40. // 16 bits for "time_hi_and_version",
  41. // four most significant bits holds version number 4
  42. mt_rand( 0, 0x0fff ) | 0x4000,
  43.  
  44. // 16 bits, 8 bits for "clk_seq_hi_res",
  45. // 8 bits for "clk_seq_low",
  46. // two most significant bits holds zero and one for variant DCE1.1
  47. mt_rand( 0, 0x3fff ) | 0x8000,
  48.  
  49. // 48 bits for "node"
  50. mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
  51. );
  52. }
  53.  
  54. public function GetSertificates($page=0) {
  55. $url = "https://www.bantikov.ru/api/get_certificates";
  56. if($this->session){
  57. $url .= "?session=".$this->session;
  58. if($page)$url .= "&page=".$page;
  59. $Sertificates = static::cURL($url,0,array(), $token);
  60. $arrSertificates = json_decode($Sertificates["RESULT"], true);
  61. return $arrSertificates;
  62. }else{
  63. echo "Не задана сессия";
  64. return false;
  65. }
  66. }
  67.  
  68. public function SendOrder($name, $phone, $email, $productID, $quantity) {
  69. $url = "https://www.bantikov.ru/api/orders";
  70. if($this->session){
  71. $arPost = array(
  72. "session" => $this->session,
  73. "name" => $name,
  74. "phone" => $phone,
  75. "email" => $email,
  76. "product_id" => $productID,
  77. "quantity" => $quantity
  78. );
  79. $Order = static::cURL($url,0,$arPost, $token);
  80. $arrOrder = json_decode($Order["RESULT"], true);
  81. file_put_contents($_SERVER["DOCUMENT_ROOT"]."/bantikov/send_order.log", date("d-m-Y H:i:s")."; ".print_r($arrOrder,1),FILE_APPEND);
  82. return $arrOrder;
  83. }else{
  84. //echo "Не задана сессия";
  85. return false;
  86. }
  87. }
  88.  
  89. public function Authorize() {
  90. $url = "https://www.bantikov.ru/api/autorize";
  91. $StoresResult = static::cURL($url,0,array("login"=>$this->login,"password"=>$this->password), "");
  92. $arrStores = json_decode($StoresResult["RESULT"], true);
  93. return $arrStores;
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment