vinelab/itunes

iTunes Store Search API Library
2,574 13
Install
composer require vinelab/itunes
Latest Version:v1.0.4
PHP:>=5.4
License:MIT
Last Updated:Jul 23, 2015
Links: GitHub  ·  Packagist
Maintainer: Vinelab

Build Status

Dependency Status

SensioLabsInsight

iTunes

A simple yet full-fledged iTunes API client with caching capabilities.

Installation

Composer

// change this to point correctly according
// to your folder structure.
require './vendor/autoload.php';

use Vinelab\ITunes\Agent as iTunes;

$iTunes = new iTunes();

$response = $iTunes->search('Porcupine Tree')); // The original iTunes response

$json = json_encode($response);

Laravel

  • Edit app.php and add 'Vinelab\ITunes\ITunesServiceProvider' to the 'providers' array. It will automatically alias itself as ITunes which can be used as a Facade class.
  • Run php artisan vendor:publish to publish the config file.

This library supports Laravel 4 and Laravel 5.x, for installation in L4 use version 1.1.x.

Usage

Search

<?php

    // Search the iTunes Store
    ITunes::search('Metallica');

    // Search the iTunes Store with custom parameters
    ITunes::search('Cannibal Corpse', array('limit'=>25, 'entity'=>'...'));

    /**
     * Search for media
     *
     * check (http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html#searching)
     * for all supported media types (the media parameter)
     */
    ITunes::music('Rolling Stones');

    ITunes::musicVideo('Immolation');

    ITunes::tvShow('Sex and The City');

In Region

You can search in a specific region by siply suffixing any media search method name with InRegion

    ITunes::musicInRegion('LB', 'Myriam Fares');

    ITunes::musicVideoInRegion('US', 'Immolation');

Lookup

<?php

    // Lookup defaults to id=...
    ITunes::lookup(490326927);

    // You can also specify the lookup request
    ITunes::lookup('amgVideoId', 17120);

    // Multiple items lookup
    ITunes::lookup('amgAlbumId', '15175,15176,15177,15178,15183,15184,15187,1519,15191,15195,15197,15198');

Caching

you can specify the duration (in minutes) of caching per request as follows

NOTE: The last cache duration value set will remain for the rest of the requests so make sure you reset afterwards.

<?php

    ITunes::cacheFor(10);
    ITunes::search('Gangnam Style'); // will be cached for 10 min.

    ITunes::cacheFor(1);
    ITunes::search('Yesterday'); // will be cached for 1 min.

    // To bypass caching pass 0
    ITunes::cacheFor(0);
    ITunes::search('Hallelujah'); // won't be cached

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

631,580,251 9,707
laravel/framework

The Laravel Framework.

580,311,802 34,925
laravel/tinker

Powerful REPL for the Laravel framework.

489,754,436 7,444
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

404,034,618 608
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

384,821,166 4,658