我今天上午也谈到这个问题——我希望台式用户通过面纱来查阅我的照片,但我希望移动用户能够直接通过URL进入用户。 和Flinoyd Wilburn一样,通过不同的URLs获取不同版本的电器是一种很好的选择,但我不使用两本复印件(硬要保存)来改写照相机/面簿,将其根成:
# rewrite both /facebook and / to same place so you
# can tell if your request came from facebook or from direct URL access :)
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} /facebook*
RewriteRule (.*) /index.php [L]
Be sure to set your Facebook page tab URL to land in the /facebook subdirectory. Now, you can browser sniff to see if they re a mobile or desktop user, and you can test the requested URL to see if they re accessing the app through Facebook or directly :)
Let me add that there is NO foolproof way to determine either the client type or access point - both can be spoofed by someone who knows what they re doing - so take this into consideration when designing your app s security and authentication mechanisms.