2
我試圖打開Facebook鏈接,並使用以下代碼將符合iOS上的URL協議。如何在iOS Facebook上加載Facebook頁面鏈接應用
NSString *url = [self.dataSource getFacebookURL];
url = [url stringByReplacingOccurrencesOfString:@"http://www.facebook.com/" withString:@"fb://profile/"];
NSLog(@"LINK: %@", url);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
但是,當試圖加載配置文件或頁面(即組織)時,它總是將我帶到最後一直打開的屏幕。有沒有直接鏈接到頁面和配置文件的方法?我遵循here所述的說明,但沒有成功。
我要鏈接到的頁面是「https://www.facebook.com/junction11」是否有幫助?
謝謝,最大
FIX
所以我找到了一個解決方案,它是裝載組/人/頁面的圖形值,解析它們,然後用Facebook-ID創建一個新的URL。代碼工作(不知道怎麼好),看起來像這樣:
// Look at graph page instead of www page
NSString *dataURL = [url stringByReplacingOccurrencesOfString:@"www" withString:@"graph"];
// Load data and parse using JSON parser
NSData *data = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:dataURL]];
NSError *error;
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
if (!error) { NSLog(@"ERROR: %@", error); return; }
// If no error occurred, make new url and replace the username by the facebook-ID
url = [url stringByReplacingOccurrencesOfString:[dictionary objectForKey:@"username"] withString:[dictionary objectForKey:@"id"]];
// And voilà, it works :]
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
謝謝谷歌和時間......
只有一個這似乎工作是'@「fb:// profile」'字符串。沒有其他的組合工作...當按照你發佈'@「fb:// page/junction11的方案''應該工作,但不。 –