Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a URL to launch a Facebook app fan page on mobile platforms?

Tags:

url

facebook

I've spent some time looking into this issue and can't find the answer.

Basically, I'm trying to write a URL using the fb:// handle that will open my Facebook's fan page on a smart phone's Facebook app.

The page below gives a list of handle codes the FB app supports, but I can't figure out how to make it launch to my page: What are all the custom URL schemes supported by the Facebook iPhone app?

I understand that my page's ID is: 212971392077465

Ultimately I want the web page I'm writing to check if the Facebook app is installed, launch it to the fan page if it is, but if not then to redirect to the fan page on http://m.facebook.com.

I want to do this rather than direct to Facebook's mobile site because if the app is installed on the user's phone, then they probably won't be authenticated on Facebook with through their browser, which would make the experience less convenient.

Then, I want to integrate this into a QR code for easier smart phone access, so people can "Like" the page in the quickest and easiest way.

Many thanks for any advice!

Ben

like image 279
Ben Avatar asked Aug 10 '11 14:08

Ben


1 Answers

I had exactly the same question. This will work:

<a href="fb://profile/212971392077465" class="facebook">My Fanpage</a>

I came up with the idea when I read this:

String uri = "fb://profile/" + yourFBpageId; 
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));   

// Add try and catch because the scheme could be changed in an update! 
// Another reason is that the Facebook-App is not installed 
try {      startActivity(intent);   
} catch (ActivityNotFoundException ex) {      
// start web browser and the facebook mobile page as fallback    
String uriMobile = "http://touch.facebook.com/pages/x/" + yourFBpageId;    
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uriMobile));    
startActivity(i); 
}

The code above would be nice to have reversed in a web URL: if the user doesn't have the Facebook app installed on the smart phone, touch.facebook or m.facebook will be launched.

Maybe it can be done with PHP.

like image 60
mecano Avatar answered Oct 15 '22 07:10

mecano