Created
June 10, 2015 07:36
-
-
Save bavington/289f5356573e1f5db645 to your computer and use it in GitHub Desktop.
Conditional buttons for Deep Linking to the Instagram App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Detect our key devices | |
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod"); | |
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone"); | |
$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad"); | |
$Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android"); | |
// if iPad or iPhone, add a deep link to launch the Instagram iOS App | |
if( $iPod || $iPhone ){ ?> | |
<a href="instagram://user?username=jamesbavington">Follow me (Launch iOS App)</a> | |
<?php } | |
// if iPad there's no iPad Instagram App, so launch in the browser | |
else if($iPad){ ?> | |
<a href="https://instagram.com/jamesbavington/" target="_blank">Follow me on Instagram</a> | |
<?php } | |
// if Android launch the Instagram Android App | |
else if($Android){ ?> | |
<a href="instagram://user?username=jamesbavington">Follow me (Launch Android App)</a> | |
<?php } | |
// for any other device, just load the Instagram Website | |
else { ?> | |
<a href="https://instagram.com/jamesbavington/" target="_blank">Follow me on Instagram</a> | |
<?php } ?> |
Its also possible by just adding the link without "https://" (e.g instargam.com/username) opens the app directly.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how do i use it. I do not have too much information
Can you help?