📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
e-ticaretv12.demodesign.com.tr
/
eklentiler
/
trendyol
📝
trendyol.class.php
← Geri Dön
<?php function get_tdCURL( $val, $post, $type, $say=0 ) { global $ayar; if ( $type == 1 ){ $url = 'https://api.trendyol.com/sapigw/suppliers/'.$ayar["td_magazaID"].'/v2/products'; // ürün ekle } elseif ( $type == 2 ){ $url = 'https://api.trendyol.com/sapigw/suppliers/'.$ayar["td_magazaID"].'/products/batch-requests/'.$val; // ürün sorgula } elseif ( $type == 3 ) { $url = 'https://api.trendyol.com/sapigw/product-categories'; // kategori sorgula } elseif ( $type == 4 ) { $url = 'https://api.trendyol.com/sapigw/brands?size=2000'; // marka sorgula } elseif ( $type == 5 ) { $url = 'https://api.trendyol.com/sapigw/shipment-providers'; // kargo sorgula } elseif ( $type == 6 ) { if ( $say == 0 ) { $say = 10; } $url = 'https://api.trendyol.com/sapigw/suppliers/'.$ayar["td_magazaID"].'/products?approved=true&size='.$say.'&page='.$val.'&dateQueryType=CREATED_DATE'; // ürünleri getir } elseif ( $type == 7 ) { $url = 'https://api.trendyol.com/sapigw/product-categories/'.$val.'/attributes'; // varyant sorgula } elseif ( $type == 8 ) { if ( $say == 0 ) { $say = 10; } $startDate = strtotime(date('Y-m-d H:i:s',strtotime("-15 day"))); $endDate = strtotime(date('Y-m-d H:i:s')); $startDate = $startDate*1000; $startDate = number_format($startDate, 0, '.', ''); $endDate = $endDate*1000; $endDate = number_format($endDate, 0, '.', ''); $url = 'https://api.trendyol.com/sapigw/suppliers/'.$ayar["td_magazaID"].'/orders/?status=Delivered&startDate='. $startDate .'&endDate='. $endDate .'&orderByField=PackageLastModifiedDate&orderByDirection=DESC&size='.$say.'&page='.$val.''; // siparişleri getir } else { $url = 'https://api.trendyol.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 ); if ( $type == 2 ){ sleep(1); } $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); curl_setopt($ch, CURLOPT_POST, $post); $header = array( 'Authorization: Basic '. base64_encode($ayar["td_apiKey"].':'.$ayar["td_apiSecret"]), 'Content-Type: application/json' ); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); if ( $post == 1 ) { curl_setopt($ch, CURLOPT_POSTFIELDS, $val); } $result = curl_exec($ch); $result = json_decode($result, true); if ( $type == 1 ) { if ( !empty($result['errors']) ) { if ( is_array($result['errors']) ) { if ( count($result['errors']) != 0 ) { $result = 0; } } } else { $result = $result['batchRequestId']; } } elseif ( $type == 2 ) { if ( !empty($result['items'][0]['status']) ) { $result = $result['items'][0]['status']; } else { $result = ''; } if ( $result == 'FAILED' ) { $result = 0; } else { $result = curl_exec($ch); $result = json_decode($result, true); if ( !empty($result['items']) and is_array($result['items']) and count($result['items']) != 0 ) { $result = 1; } else { $result = 0; } } } elseif ( $type == 3 ) { $result = $result['categories']; } elseif ( $type == 4 ) { $result = $result['brands']; } elseif ( $type == 6 ) { $result = $result['content']; } elseif ( $type == 7 ) { if ( !empty($result['categoryAttributes']) ) { $result = $result['categoryAttributes']; } else { $result = $result; } } elseif ( $type == 8 ) { if ( !empty($result['content']) and count($result['content']) > 0 ) { $result = $result['content']; } else { $result = array(); } } else { $result = $result; } return $result; } function tdCatSearch( $array, $value ) { $data[] = array(); if ( !empty($value) ) { for ( $i=0; $i<count($array); $i++ ) { $i_sub = $array[$i]['subCategories']; if ( strpos($array[$i]['name'],$value) !== false ) { $data[] = $array[$i]['id']; if ( count($array[$i]['subCategories']) != 0 ) { $data[] = $array[$i]['id'][0]; } else { $data[] = $array[$i]['id']; } } else { if ( !empty($i_sub) ) { for ( $j=0; $j<count($i_sub); $j++ ) { if ( !empty($i_sub[$j]['subCategories']) ) { $j_sub = $i_sub[$j]['subCategories']; } else { $j_sub = array(); } if ( !empty($i_sub[$j]['name']) and strpos($i_sub[$j]['name'],$value) !== false ) { if ( count($i_sub[$j]['subCategories']) != 0 ) { $data[] = $i_sub[$j]['id'][0]; } else { $data[] = $i_sub[$j]['id']; } } else { if ( !empty($j_sub) ) { for ( $c=0; $c<count($j_sub); $c++ ) { if ( !empty($j_sub[$c]['subCategories']) ) { $c_sub = $j_sub[$c]['subCategories']; } else { $c_sub = array(); } if ( !empty($j_sub[$c]['name']) and strpos($j_sub[$c]['name'],$value) !== false ) { if ( count($j_sub[$c]['subCategories']) != 0 ) { $data[] = $j_sub[$c]['id'][0]; } else { $data[] = $j_sub[$c]['id']; } } else { if ( !empty($c_sub) ) { for ( $e=0; $e<count($c_sub); $e++ ) { if ( !empty($c_sub[$e]['subCategories']) ) { $e_sub = $c_sub[$e]['subCategories']; } else { $e_sub = array(); } if ( !empty($c_sub[$e]['name']) and strpos($c_sub[$e]['name'],$value) !== false ) { if ( count($c_sub[$e]['subCategories']) != 0 ) { $data[] = $c_sub[$e]['id'][0]; } else { $data[] = $c_sub[$e]['id']; } } else { if ( !empty($e_sub) ) { for ( $f=0; $f<count($e_sub); $f++ ) { if ( !empty($e_sub[$f]['subCategories']) ) { $f_sub = $e_sub[$f]['subCategories']; } else { $f_sub = array(); } if ( !empty($e_sub[$f]['name']) and strpos($e_sub[$f]['name'],$value) !== false ) { if ( count($e_sub[$f]['subCategories']) != 0 ) { $data[] = $e_sub[$f]['id'][0]; } else { $data[] = $e_sub[$f]['id']; } } else { if ( !empty($f_sub) ) { for ( $g=0; $g<count($f_sub); $g++ ) { if ( !empty($f_sub[$g]['name']) and strpos($f_sub[$g]['name'],$value) !== false ) { if ( count($f_sub[$g]['subCategories']) != 0 ) { $data[] = $f_sub[$g]['id'][0]; } else { $data[] = $f_sub[$g]['id']; } } else { $data[] = 0; } } } } } } } } } } } } } } } } } } $result = 0; foreach ( $data as $val ) { if ( $val != 0 ) { $result = $val; } } if ( is_array($result) ) { if ( count($result) == 0 ) { $result = 0; } } if ( $result == 0 ) { $result = array_rand($array); $result = $array[$result]['id']; } return $result; } function tdBrandSearch( $array, $value ) { $data = array(); if ( !empty($value) ) { for ( $i=0; $i<count($array); $i++ ) { if ( !empty($array[$i]['name']) ) { if ( strpos($array[$i]['name'], "$value") !== false ) { $data[] = $array[$i]['id']; } } } } $result = array(); foreach ( $data as $val ) { if ( $val != 0 ) { $result[] = $val; } } if ( !empty($result[0]) ) { $result = $result[0]; } else { $result = 0; } if ( $result == 0 ) { $result = array_rand($array); $result = $array[$result]['id']; } return $result; } function tdCargoSearch( $array, $value ) { $data = array(); for ( $i=0; $i<count($array); $i++ ) { if ( strpos($array[$i]['name'], "$value") !== false ) { $data[] = $array[$i]['id']; } } $result = array(); foreach ( $data as $val ) { if ( $val != 0 ) { $result[] = $val; } } if ( !empty($result[0]) ) { $result = $result[0]; } else { $result = 0; } if ( $result == 0 ) { $result = array_rand($array); $result = $array[$result]['id']; } return $result; } function tdVaryantGet( $array ) { $data = ''; if ( is_array($array) ) { for ( $i=0; $i<count($array); $i++ ) { if ( !empty($array[$i]['required']) and $array[$i]['required'] == 1 ) { if ( !empty($array[$i]['allowCustom']) and $array[$i]['allowCustom'] == 1 ) { $value = '{ "attributeId": '. $array[$i]["attribute"]["id"] .', "attributeValueId": "", "customAttributeValue": "Beyaz" }'; } else { $value = '{ "attributeId": '. $array[$i]["attribute"]["id"] .', "attributeValueId": '. $array[$i]["attributeValues"][0]["id"] .' }'; } $data .= $value . ','; } } } $data = rtrim($data,','); return $data; }
💾 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