Skip to content

Instantly share code, notes, and snippets.

@blech
Created May 13, 2013 18:14
Show Gist options
  • Save blech/5570261 to your computer and use it in GitHub Desktop.
Save blech/5570261 to your computer and use it in GitHub Desktop.
Flipboard's UA dependent short URL expansion
Flipboard short URL http://flip.it/VjRUL with iPhone UA:
$ curl -A "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5" http://flip.it/VjRUL
<iframe id="appLoader" style="display:none;"></iframe>
<script>
var flipboardURL = 'flipboard://showSection/flipboard%2Fsingleurl%252Fhttp%253A%252F%252Ft.co%252Fo9hDkbJXl3?resetStack=true&referrer=twitter&createDevice=iphone&canAddToFlipboard=false&createAction=shareWithComment&showPreselectedItem=true';
var appStoreURL = "http://ax.itunes.apple.com/us/app/flipboard/id358801284?mt=8";
var googlePlayURL = "https://play.google.com/store/apps/details?id=flipboard.app&feature=nav_result#?t=W251bGwsMSwyLDNd";
// try and launch Flipboard with the add section url
if(navigator.userAgent.match(/android/i) != null){
document.getElementById("appLoader").setAttribute("src", flipboardURL);
}
if(navigator.userAgent.match(/iPad/i) != null || navigator.userAgent.match(/iPhone/i) != null){
window.location.href = flipboardURL;
}
// if that failed, quickly try and launch the dont have flipboard URL
setTimeout(function(){
window.location.href = 'http://t.co/o9hDkbJXl3';
},50)
</script>
--
Without iPhone UA:
$ curl http://flip.it/VjRUL
<html><body>You are being <a href="http://www.guardian.co.uk/artanddesign/2013/may/13/tate-britain-scraps-panels-art">redirected</a>.</body></html>
Headers:
$ curl -D - http://flip.it/VjRUL -o /dev/null
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0HTTP/1.1 302 Found
Server: nginx/1.1.19
Date: Mon, 13 May 2013 18:13:22 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 147
Connection: keep-alive
Status: 302 Found
Cache-Control: no-cache
Location: http://www.guardian.co.uk/artanddesign/2013/may/13/tate-britain-scraps-panels-art
Access-Control-Allow-Origin: *
Access-Control-Request-Method: *
X-UA-Compatible: IE=Edge,chrome=1
X-Runtime: 0.197909
Via: 1.1 flland.flipboard.com
Vary: Accept-Encoding
X-Varnish: 1886696604 1886696357
Age: 100
Via: 1.1 varnish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment