Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open facebook page in facebook app in iphone?

Tags:

I have the following page I want to show in facebook app: http://www.facebook.com/mypage

I try to do the following but it doesn't seem to work:

    NSURL *urlApp = [NSURL URLWithString:@"fb://profile/mypage"];
    [[UIApplication sharedApplication] openURL:urlApp];

also I tried @"fb://mypage" with the same negative result. Application is open but without the page needed.

like image 299
Alexey Avatar asked Jan 24 '12 09:01

Alexey


People also ask

Does iPhone have a Facebook page?

Apple doesn't actually have a Facebook page for iPhone. In fact, Apple's presence on Facebook is inconsistent. There is a page for the App Store.


2 Answers

To open facebook page in facebook app you should:

1)Find uid of your page (it can be done for example by looking at source code of your facebook page)

I got the following fragment from the source code of the page: http://www.facebook.com/yourpage

{"text":"yourpage","type":"ent:page","uid":****123****}

N.B.: To check if uid is correct substitute uid for pagename: http://www.facebook.com/****123**** This url should open your page.

2) When the uid is found and is correct use this code:

NSURL *urlApp = [NSURL URLWithString:@"fb://profile/****123****"];
[[UIApplication sharedApplication] openURL:urlApp];

This code will open you page within facebook app. N.B.: Do not forget to check if the facebook app exists( or more precisely that the url can be opened) using: if ([[UIApplication sharedApplication] canOpenURL:urlApp]) otherwise open it in Safari.

like image 107
Alexey Avatar answered Jan 04 '23 04:01

Alexey


Another quick method is to use the facebook graph API e.g

https://graph.facebook.com/name-of-your-page-here

I used this to find the leeds uni page like so:

https://graph.facebook.com/universityofleeds

The results were as shown below, the id is the first element (highlighted) results of the facebook graph call

You will use it in your application like so

    NSURL *url = [NSURL URLWithString:@"fb://profile/93693583250"];
    [[UIApplication sharedApplication] openURL:url];
like image 35
Edwin Avatar answered Jan 04 '23 04:01

Edwin