PHP code example of dmm / affiliate

1. Go to this page and download the library: Download dmm/affiliate library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dmm / affiliate example snippets




DMM\Affiliate;

$dmm = new Affiliate('HnewL5HcLPsefmeUpzL0', 'pornjapan-990');
$dmm->setKeyword('スク水');
$array = $dmm->getResult();


foreach ($array->result->items->item as $item) {
    $title = $item->title;
    $affiliate_url = $item->affiliateURL;


    if (!isset($item->sampleImageURL->sample_s)) {
        continue;
    }


    $image_url = $item->sampleImageURL->sample_s->image[7];

    print sprintf('<li><a href="%s" title="%s" target="dmm"><img alt="%s" src="%s"></a></li>', $affiliate_url, $title, $title, $image_url);
    print "\n";
}


% php composer.phar install