Memention Blog

Open AppStore with a search expression


Update: Remember always to check stackoverflow first. I found an easier way to accomplish the same thing there. See stackoverflow question 818973 See also the iTunes Link Maker from Apple

It has been fairly easy on the desktop to open iTunes with all the iPhone apps from a developer. Doing the same on the iPhone has been practically impossible, but the other day (or rather night) I managed to solve this problem. By using the URL protocol for the AppStore on the iPhone with a specially crafted web search access AppStore will open with a predefined search expression. Neat.

After I solved this little interesting problem I wrote a small php script that check the useragent string. If the string contain the word iPhone a redirect to the URL that open the AppStore app is returned. Otherwise a redirect to a normal web page is returned.

Below you can see this short php script. I have separated the AppStore URL into three parts so it doesn’t wrap in the browser.

File: Active link more.php

<html>
  <head>
<?php
  $part1 = "itms-apps://ax.search.itunes.apple.com";
  $part2 = "/WebObjects/MZSearch.woa/wa/search?media=software&term=";
  $part3 = "Memention%20AB"; // Place the desired search string here, escape spaces
  $userAgent = $_SERVER['HTTP_USER_AGENT'];
  if ((''==$userAgent) || (FALSE !== strpos($userAgent,'iPhone')))
  {
    // This part will be returned to an iPhone
?>
    <meta http-equiv="Refresh" content="0; url=<?php echo "$part1$part2$part3"; ?>">
<?php
  }
  else
  {
    // This part will be returned to anything not an iPhone, change target URL
?>
    <meta http-equiv="Refresh" content="0; url=/software.html">
<?php
  }
?>
  </head>
  <body>
  </body>
</html>
By Edward Patel, 15 Aug 2009




Show comments

Archive

Getting there13 Mar 2014
Throwing pebbles12 Jul 2013
Provision this!30 Aug 2012
Break what?18 Aug 2011
That old thing04 May 2011
Removing a Step15 May 2010
Make It Work22 Feb 2010
KISS server31 Jan 2010
tig on Mac12 Dec 2009
The XML Runner31 Oct 2009
Get some software from Memention
Powered by Jekyll and Disqus.
Copyright © 2010-2013 Memention AB