Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get itunes id from url

Tags:

regex

php

what is the best way to retrieve id from itunes app link?

let say i have these link:

http://itunes.apple.com/us/app/bring-me-sandwiches!!/id457603026?mt=8

http://itunes.apple.com/us/app/bring-me-sandwiches!!/id457603026

i just want to get the id, 457603026 using php preg_match

like image 419
od3n Avatar asked Dec 02 '11 04:12

od3n


People also ask

How do I get iTunes ID?

From the menu bar at the top of your computer screen or at the top of the iTunes window, choose Account > Sign In. Then click Create New Apple ID. Enter your credit card and billing information, then click Continue. You can also choose None, and learn what to do if None isn't showing or you can't select it.

Is iTunes account same as Apple ID?

An Apple ID is the email address you use as a login for just about everything you do with Apple, including using iCloud to store your content, buying songs from the iTunes Store, and downloading apps from the App Store. An iCloud account, iTunes account and Apple ID are all the same thing.

How do I copy a URL from iTunes?

The quickest way to get a link is to Control-click or right-click on a song in the iTunes Music Store. A contextual menu pops up. Select Copy iTunes Music Store URL and simply paste the URL into an email or HTML page.


1 Answers

Without preg_match:

$url = 'http://itunes.apple.com/us/app/bring-me-sandwiches!!/id457603026?mt=8';
echo end(explode('/id', parse_url($url, PHP_URL_PATH)));

or, if you prefer:

$url = 'http://itunes.apple.com/us/app/bring-me-sandwiches!!/id457603026?mt=8';
$id = explode('/id', parse_url($url, PHP_URL_PATH));
echo $id[1];
like image 176
Book Of Zeus Avatar answered Oct 23 '22 11:10

Book Of Zeus