Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- class Bantikov
- {
- public $login = "farmclub"; //"test_api_client"
- public $password = "VqKiJ5xVsQm754SjWzRr"; //"u5h7kpnsePexpjhPfc4A"
- public $session = false;
- public function cURL($url, $cookie, $p, $token){
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
- curl_setopt($ch, CURLOPT_REFERER, 'http://'.$_SERVER["SERVER_NAME"].'/');
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- if($token)curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'X-Authorization: '.$token));
- if ($p) {
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $p);
- }
- $result = curl_exec($ch);
- $info = curl_getinfo($ch);
- curl_close($ch);
- if ($result){
- return array("RESULT" => $result, "HEADERS" => $info);
- }else{
- return '';
- }
- }
- public function gen_uuid() {
- return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
- // 32 bits for "time_low"
- mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
- // 16 bits for "time_mid"
- mt_rand( 0, 0xffff ),
- // 16 bits for "time_hi_and_version",
- // four most significant bits holds version number 4
- mt_rand( 0, 0x0fff ) | 0x4000,
- // 16 bits, 8 bits for "clk_seq_hi_res",
- // 8 bits for "clk_seq_low",
- // two most significant bits holds zero and one for variant DCE1.1
- mt_rand( 0, 0x3fff ) | 0x8000,
- // 48 bits for "node"
- mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
- );
- }
- public function GetSertificates($page=0) {
- $url = "https://www.bantikov.ru/api/get_certificates";
- if($this->session){
- $url .= "?session=".$this->session;
- if($page)$url .= "&page=".$page;
- $Sertificates = static::cURL($url,0,array(), $token);
- $arrSertificates = json_decode($Sertificates["RESULT"], true);
- return $arrSertificates;
- }else{
- echo "Не задана сессия";
- return false;
- }
- }
- public function SendOrder($name, $phone, $email, $productID, $quantity) {
- $url = "https://www.bantikov.ru/api/orders";
- if($this->session){
- $arPost = array(
- "session" => $this->session,
- "name" => $name,
- "phone" => $phone,
- "email" => $email,
- "product_id" => $productID,
- "quantity" => $quantity
- );
- $Order = static::cURL($url,0,$arPost, $token);
- $arrOrder = json_decode($Order["RESULT"], true);
- file_put_contents($_SERVER["DOCUMENT_ROOT"]."/bantikov/send_order.log", date("d-m-Y H:i:s")."; ".print_r($arrOrder,1),FILE_APPEND);
- return $arrOrder;
- }else{
- //echo "Не задана сессия";
- return false;
- }
- }
- public function Authorize() {
- $url = "https://www.bantikov.ru/api/autorize";
- $StoresResult = static::cURL($url,0,array("login"=>$this->login,"password"=>$this->password), "");
- $arrStores = json_decode($StoresResult["RESULT"], true);
- return $arrStores;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment