Friday, June 21, 2013

[SHARE] PHP code membuat AGC Untuk Amazon Coupon Website [yang suka auto2 aja]

 

 

Feed: Arsip
Posted on: Friday, June 21, 2013 01:49
Author: keblux
Subject: [SHARE] PHP code membuat AGC Untuk Amazon Coupon Website [yang suka auto2 aja]

 

niatnya mau buat web coupon dapet ide bikin web coupon khusus amazon, karena ane liat banyakan astore amazon sama affiliate produk2 amazon aja. tapi baru setengah jalan ud males jadi ane share aja php class buat grab amazon coupon silahkan dikembangkan, kritik dan saran dipersilahkan :D

amazon coupon php class

PHP Code:


<?php
class amzCoupon {
     
    public 
$affiliate_id;
    public 
$amazon_catid;
    private 
$agent 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0'
    
    private function 
amz_curl($url,$referer){
    
$cookiefile tempnam("""tmp_cookie");
        
$ch curl_init();
        
curl_setopt($chCURLOPT_URL$url);
        
curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
curl_setopt($chCURLOPT_REFERER$referer);
        
curl_setopt($chCURLOPT_USERAGENT$this->agent);
        
curl_setopt($chCURLOPT_COOKIEJAR$cookiefile);
        
curl_setopt($chCURLOPT_COOKIEFILE$cookiefile);

        
$result curl_exec($ch);
        
curl_close($ch);
        return 
$result;
    }

   private function 
amz_getHTML() {
            
$url "www.amazon.com/gp/feature.html/?ie=UTF8&docId=".$this->amazon_catid;
            return 
$this::amz_curl($url,"http://www.amazon.com/");
    }

    private function 
amz_extractData() {
          
$data $this::amz_getHTML();
          
$data=str_replace('coupon-box-tr','<keblux>',$data);
          
$data explode('<keblux>',$data);
          
$x=0;
            foreach(
$data as $item){
                if(
$x>1){
                
$item str_replace('coupon-item-title','"><keblux>',$item);
                
$item str_replace('coupon-box-img','"><keblux>',$item);
                
$item str_replace('coupon-item-desc','"><keblux>',$item);
                
$this_item=explode('<keblux>',$item);
                
$title $this_item[1];
                
$title trim(strip_tags($title));
                
$title =str_replace('">','',$title);
                
$image=$this_item[2];
                
$image str_replace('<img','<keblux><img',$image);
                
$image str_replace('</a>','<keblux>,</a>',$image);
                
$image =explode('<keblux>',$image);
                
$image =$image[1];
                
$id=str_replace('http://ecx.images-amazon.com/images/I/','<keblux>',$image);
                
$id=str_replace('._SL500_SS115_.jpg','<keblux>',$id);
                
$id=    explode('<keblux>',$id);
                
$id=$id[1];
                
$prod_title=$this_item[3];
                
$prod_title=str_replace('</a>','<keblux>',$prod_title);
                
$prod_title=explode('<keblux>',$prod_title);
                
$prod_title=$prod_title[0];
                
$prod_title=trim(strip_tags($prod_title));
                
$prod_title=str_replace('">','',$prod_title);
                
                
$title=trim($title);
                
$image =trim($image);
                
$prod_title=trim($prod_title);
                
$id=trim($id);
                
$res[$x]['id'] = $id;
                
$res[$x]['title'] = $title;
                
$res[$x]['image'] = $image;
                
$res[$x]['prod_title'] = $prod_title;
                
$res[$x]['cat_id'] = $this->amazon_catid;
            }
      
$x++;
      }
      return 
array_values($res);
    }

    public function 
amz_createHTML() {
        
$datas $this::amz_extractData();
        
$shortcode_output NULL;
        foreach(
$datas as $data) {
        
$shortcode_output .=  '<div id="coupon_content"><a href="http://www.amazon.com/gp/feature.html/?docId='.$data['cat_id'].'&tag='.$this->affiliate_id.'" target="_blank" rel="nofollow">
                        <div id="coupon_content_title">'
.$data['title'].'</div>
                        <div id="coupon_content_image">'
.$data['image'].'</div>
                        <div id="coupon_content_text">'
.$data['prod_title'].'</div>
                        <div id="coupon_button">View</div>
                        </a></div>'
;  
        }      
        return 
$shortcode_output;
    } 
}
?>


short desc cara pakai

PHP Code:


<style>
#coupon_content{text-align:center; margin:5px;padding:5px;float:left;width:160px;height:245px; display: block;}
#coupon_content a{text-decoration:none;}
#coupon_content:hover {    -moz-box-shadow: 0 0 7px rgba(0,0,0,0.5);    -webkit-box-shadow: 0 0 7px rgba(0,0,0,0.5);    box-shadow: 0 0 7px rgba(0,0,0,0.5);    }
#coupon_content_title{color: #E47911;font-size: 14pt;font-weight: bold;text-align: center; }
#coupon_content_text{color: #004B91; }
#coupon_button{margin-top:10px; }
</style>
<?php
    $amazon_coupon 
= new amzCoupon();
    
$amazon_coupon->affiliate_id 'AFFILIATE_AMAZON_ID'//ganti dengan affiliate id amazon agan
    
$amazon_coupon->amazon_catid =  1000819331//ganti dengan category amazon
    
echo $amazon_coupon->amz_createHTML();
?>


Full code untuk test

PHP Code:


<?php
class amzCoupon {
     
    public 
$affiliate_id;
    public 
$amazon_catid;
    private 
$agent 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0'
    
    private function 
amz_curl($url,$referer){
    
$cookiefile tempnam("""tmp_cookie");
        
$ch curl_init();
        
curl_setopt($chCURLOPT_URL$url);
        
curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
curl_setopt($chCURLOPT_REFERER$referer);
        
curl_setopt($chCURLOPT_USERAGENT$this->agent);
        
curl_setopt($chCURLOPT_COOKIEJAR$cookiefile);
        
curl_setopt($chCURLOPT_COOKIEFILE$cookiefile);

        
$result curl_exec($ch);
        
curl_close($ch);
        return 
$result;
    }

   private function 
amz_getHTML() {
            
$url "www.amazon.com/gp/feature.html/?ie=UTF8&docId=".$this->amazon_catid;
            return 
$this::amz_curl($url,"http://www.amazon.com/");
    }

    private function 
amz_extractData() {
          
$data $this::amz_getHTML();
          
$data=str_replace('coupon-box-tr','<keblux>',$data);
          
$data explode('<keblux>',$data);
          
$x=0;
            foreach(
$data as $item){
                if(
$x>1){
                
$item str_replace('coupon-item-title','"><keblux>',$item);
                
$item str_replace('coupon-box-img','"><keblux>',$item);
                
$item str_replace('coupon-item-desc','"><keblux>',$item);
                
$this_item=explode('<keblux>',$item);
                
$title $this_item[1];
                
$title trim(strip_tags($title));
                
$title =str_replace('">','',$title);
                
$image=$this_item[2];
                
$image str_replace('<img','<keblux><img',$image);
                
$image str_replace('</a>','<keblux>,</a>',$image);
                
$image =explode('<keblux>',$image);
                
$image =$image[1];
                
$id=str_replace('http://ecx.images-amazon.com/images/I/','<keblux>',$image);
                
$id=str_replace('._SL500_SS115_.jpg','<keblux>',$id);
                
$id=    explode('<keblux>',$id);
                
$id=$id[1];
                
$prod_title=$this_item[3];
                
$prod_title=str_replace('</a>','<keblux>',$prod_title);
                
$prod_title=explode('<keblux>',$prod_title);
                
$prod_title=$prod_title[0];
                
$prod_title=trim(strip_tags($prod_title));
                
$prod_title=str_replace('">','',$prod_title);
                
                
$title=trim($title);
                
$image =trim($image);
                
$prod_title=trim($prod_title);
                
$id=trim($id);
                
$res[$x]['id'] = $id;
                
$res[$x]['title'] = $title;
                
$res[$x]['image'] = $image;
                
$res[$x]['prod_title'] = $prod_title;
                
$res[$x]['cat_id'] = $this->amazon_catid;
            }
      
$x++;
      }
      return 
array_values($res);
    }

    public function 
amz_createHTML() {
        
$datas $this::amz_extractData();
        
$shortcode_output NULL;
        foreach(
$datas as $data) {
        
$shortcode_output .=  '<div id="coupon_content"><a href="http://www.amazon.com/gp/feature.html/?docId='.$data['cat_id'].'&tag='.$this->affiliate_id.'" target="_blank" rel="nofollow">
                        <div id="coupon_content_title">'
.$data['title'].'</div>
                        <div id="coupon_content_image">'
.$data['image'].'</div>
                        <div id="coupon_content_text">'
.$data['prod_title'].'</div>
                        <div id="coupon_button">View</div>
                        </a></div>'
;  
        }      
        return 
$shortcode_output;
    } 
}
?>
<style>
#coupon_content{text-align:center; margin:5px;padding:5px;float:left;width:160px;height:245px; display: block;}
#coupon_content a{text-decoration:none;}
#coupon_content:hover {    -moz-box-shadow: 0 0 7px rgba(0,0,0,0.5);    -webkit-box-shadow: 0 0 7px rgba(0,0,0,0.5);    box-shadow: 0 0 7px rgba(0,0,0,0.5);    }
#coupon_content_title{color: #E47911;font-size: 14pt;font-weight: bold;text-align: center; }
#coupon_content_text{color: #004B91; }
#coupon_button{margin-top:10px; }
</style>
<?php
    $amazon_coupon 
= new amzCoupon();
    
$amazon_coupon->affiliate_id 'AFFILIATE_AMAZON_ID'//ganti dengan affiliate id amazon agan
    
$amazon_coupon->amazon_catid =  1000819331//ganti dengan category amazon
    
echo $amazon_coupon->amz_createHTML();
?>


Penampakan
h4fjj6r.png

semoga dapat berguna buat para warga disini. amin..

Attached Images