PHP code example of yasukei / dmm-api-client-php

1. Go to this page and download the library: Download yasukei/dmm-api-client-php 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/ */

    

yasukei / dmm-api-client-php example snippets


use DmmApiClient\Api\DmmApiClient;
use DmmApiClient\Api\Request\Credentials;
use DmmApiClient\Api\Request\ItemListRequest;
use DmmApiClient\Api\Request\ItemListSort;

$client = new DmmApiClient(new Credentials('your_api_id', 'your_affiliate_id'));

$response = $client->itemList(new ItemListRequest(
    site: 'DMM.com',
    service: 'mono',
    floor: 'book',
    keyword: 'PHP',
    sort: ItemListSort::Date,
    hits: 20,
));

echo $response->result->totalCount, " 件\n";

foreach ($response->result->items as $item) {
    echo $item->contentId, ' ', $item->title, ' ', $item->prices?->price, "\n";
}

var_dump($response->json()); // API が返した JSON をそのまま(DTO が知らない項目も含む)