Skip to content

Instantly share code, notes, and snippets.

@raphaelz
Created April 22, 2015 18:26
Show Gist options
  • Save raphaelz/7d8f2c429ca435e18118 to your computer and use it in GitHub Desktop.
Save raphaelz/7d8f2c429ca435e18118 to your computer and use it in GitHub Desktop.
Grab Apple Watch screenshots for apps using iTunes URL. Inspired by @stroughtonsmith
<?php
$screenshots = array();
$url = 'https://itunes.apple.com/us/app/citymapper-ultimate-real-time/id469463298?mt=8';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "AppleWatchStore/1 CFNetwork/720.2.4 Darwin/14.1.0 (x86_64)");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Apple-Store-Front: 143441-1,20'));
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = json_decode(curl_exec($ch));
preg_match('/id(\d+)/', $url, $matches);
$id = $matches[1];
$screenshotsArr = $content->storePlatformData->{'product-dv-product'}->results->{$id}->screenshotsByType->appleWatch;
foreach($screenshotsArr as $screenshot) {
$screenshot = $screenshot[0];
$screenshots[] = $screenshot->url;
}
print_r($screenshots);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment