📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
e-ticaretv12.demodesign.com.tr
/
eklentiler
/
hepsiburada
📝
hepsiburada.class.php
← Geri Dön
<?php function get_hpCURL( $val, $post, $type ) { global $ayar; global $_SESSION; $data = json_encode($val); if ( $type == 1 ) { $url = 'https://mpop.hepsiburada.com/api/authenticate'; // token alma } elseif ( $type == 2 ) { $url = 'https://mpop.hepsiburada.com/product/api/categories/get-all-categories?leaf=true&status=ACTIVE&available=true&page=0&size=2000&version=1'; // kategori çekme } elseif ( $type == 3 ) { $url = 'https://mpop.hepsiburada.com/product/api/categories/'.$val.'/attributes'; // kategori özelliği çekme } elseif ( $type == 4 ) { $url = 'https://mpop.hepsiburada.com/product/api/categories/'.$val[0].'/attribute/'.$val[1]; // varyant çekme } elseif ( $type == 5 ) { $url = 'https://mpop.hepsiburada.com/product/api/products/import'; // ürün ekle } elseif ( $type == 6 ) { $url = 'https://mpop.hepsiburada.com/product/api/products/status/'.$val.'?page=0&size=1&version=1'; // ürün sorgula } elseif ( $type == 7 ) { $url = 'https://listing-external.hepsiburada.com/listings/merchantid/'.$ayar["hb_MerchantID"].'?offset='.$val[0].'&limit='.$val[1]; // ürünleri getir } elseif ( $type == 8 ) { $url = 'https://oms-external.hepsiburada.com/orders/merchantid/'.$ayar["hb_MerchantID"].'?offset='.$val[0].'&limit='.$val[1]; // siparişleri getir } else { $url = 'https://mpop.hepsiburada.com'; } $options = array( CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => "", CURLOPT_USERAGENT => "spider", CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120, CURLOPT_MAXREDIRS => 10, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false ); if ( $type == 6 ){ sleep(1); } $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); curl_setopt($ch, CURLOPT_POST, $post); if ( $type == 7 or $type == 8 ) { $header = array( 'Authorization: Basic '. base64_encode($ayar['hb_username'].':'.$ayar['hb_password']), 'Content-Type: application/xml' ); } else { if ( empty($_SESSION['id_token']) ){ $header = array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data) ); } else { if ( $type == 5 ) { $uri = '../eklentiler/hepsiburada/json/' . md5(uniqid()).'.json'; $json = fopen( $uri, 'w' ); fwrite($json, $data) ; fclose($json); $delimiter = '-------------'.uniqid(); $file = new oFile($uri, 'text/plain', 'Content file'); $data = BodyPost::Get(array('file'=>$file), $delimiter); $header = array( 'Authorization: Bearer '. $_SESSION['id_token'], 'Content-Type: multipart/form-data; boundary=' . $delimiter, 'Content-Length: ' . strlen($data) ); } else { $header = array( 'Authorization: Bearer '. $_SESSION['id_token'], 'Content-Type: application/json' ); } } } curl_setopt($ch, CURLOPT_HTTPHEADER, $header); if ( $post == 1 ) { curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } $result = curl_exec($ch); $result = json_decode($result, true); if ( $type == 1 ){ $_SESSION['id_token'] = $result['id_token']; } elseif ( $type == 2 ) { if ( $result['success'] == 1 ) { $result = $result['data']; } } elseif ( $type == 3 ) { if ( $result['success'] == 1 ) { $result = $result['data']; } } elseif ( $type == 4 ) { if ( $result['success'] == 1 ) { $result = $result['data']; } } elseif ( $type == 5 ) { if ( $result['success'] == 1 ) { $result = $result['data']['trackingId']; } else { $result = 0; } } elseif ( $type == 6 ) { if ( $result['success'] == 1 ) { $result = 1; } else { $result = 0; } } elseif ( $type == 7 ) { if ( empty($result) ) { $result = array(); } } elseif ( $type == 8 ) { $result = $result['items']; } return $result; } class oFile { private $name; private $mime; private $content; public function __construct($name, $mime=null, $content=null){ if(is_null($content)){ $info = pathinfo($name); if(!empty($info['basename']) && is_readable($name)){ $this->name = $info['basename']; $this->mime = mime_content_type($name); $content = file_get_contents($name); if($content!==false) $this->content = $content; else throw new Exception('Don`t get content - "'.$name.'"'); } else throw new Exception('Error param'); } else { $this->name = $name; if(is_null($mime)) $mime = mime_content_type($name); $this->mime = $mime; $this->content = $content; } } public function Name() { return $this->name; } public function Mime() { return $this->mime; } public function Content() { return $this->content; } }; class BodyPost { public static function PartPost($name, $val){ $body = 'Content-Disposition: form-data; name="' . $name . '"'; if($val instanceof oFile){ $file = $val->Name(); $mime = $val->Mime(); $cont = $val->Content(); $body .= '; filename="' . $file . '"' . "\r\n"; $body .= 'Content-Type: ' . $mime ."\r\n\r\n"; $body .= $cont."\r\n"; } else { $body .= "\r\n\r\n".urlencode($val)."\r\n"; } return $body; } public static function Get(array $post, $delimiter='-------------0123456789'){ if(is_array($post) && !empty($post)){ $bool = false; foreach($post as $val) if($val instanceof oFile) {$bool = true; break; }; if($bool){ $ret = ''; foreach($post as $name=>$val) $ret .= '--' . $delimiter. "\r\n". self::PartPost($name, $val); $ret .= "--" . $delimiter . "--\r\n"; } else $ret = http_build_query($post); } else throw new \Exception('Error input param!'); return $ret; } };
💾 Kaydet
İptal
📝 Yeniden Adlandır
İptal
Kaydet
🔐 Dosya İzinleri (chmod)
İzin Değeri:
Hızlı Seçim:
777
755
644
600
777
= Herkes okur/yazar/çalıştırır
755
= Sahip tam, diğerleri okur/çalıştırır
644
= Sahip okur/yazar, diğerleri okur
600
= Sadece sahip okur/yazar
İptal
Uygula