Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Prosperent($term, $x=0, $perlu='keyword'){
- $api = '51bf441d80d02bbad997b0feb2896ccf';
- $url = 'http://api.prosperent.com/api/search?api_key='.$api.'&query='.urlencode($term);
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_RETURNTRANSFER => 1,
- CURLOPT_URL => $url,
- CURLOPT_CONNECTTIMEOUT => 30,
- CURLOPT_TIMEOUT => 30
- ));
- $response = curl_exec($curl);
- curl_close($curl);
- $response = json_decode($response, true);
- if (count($response['errors']))
- {
- throw new Exception(implode('; ', $response['errors']));
- }
- $data = $response['data'];
- if(!empty($data)){
- $array = array();
- foreach ($data as $key => $value){
- $item = array(
- 'title' => $value['keyword'],
- 'desc' => $value['description'],
- 'img' => $value['image_url'],
- 'link' => $value['affiliate_url'],
- 'price' => $value['price'],
- 'currency' => $value['currency'],
- 'merchant' => $value['merchant'],
- 'brand' => $value['brand'],
- );
- array_push($array, $item);
- }
- foreach($array as $a){
- $desc[] = $a['desc'];
- $title[] = $a['title'];
- $link[] = $a['link'];
- $img[] = $a['img'];
- $price[] = $a['price'];
- $currency[] = $a['currency'];
- $merchant[] = $a['merchant'];
- $brand[] = $a['brand'];
- }
- $deskripsi = array_unique($desc);
- $judul = array_unique($title);
- $url = array_unique($link);
- $gambar = array_unique($img);
- $hrg = array_unique($price);
- $matauang = array_unique($currency);
- $toko = array_unique($merchant);
- $produk = array_unique($brand);
- if($perlu == 'aff'){
- if(!empty($url[$x])){$isi = $url[$x];} else {$isi = '';}
- } else if($perlu == 'gbr'){
- if(!empty($gambar[$x])){$isi = $gambar[$x];} else {$isi = '';}
- } else if($perlu == 'desc'){
- if(!empty($deskripsi[$x])){$isi = filterku($deskripsi[$x]);} else {$isi = '';}
- } else if($perlu == 'hrg'){
- if(!empty($hrg[$x])){$isi = $hrg[$x];} else {$isi = '';}
- } else if($perlu == 'uang'){
- if(!empty($matauang[$x])){$isi = $matauang[$x];} else {$isi = '';}
- } else if($perlu == 'toko'){
- if(!empty($toko[$x])){$isi = $toko[$x];} else {$isi = '';}
- } else if($perlu == 'produk'){
- if(!empty($produk[$x])){$isi = $produk[$x];} else {$isi = '';}
- } else {
- if(!empty($judul[$x])){$isi = filterku($judul[$x]);} else {$isi = '';}
- }
- return $isi;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement