iPad:无法在UIWebview中加载Facebook页面墙 [英] iPad: Cannot load facebook page wall in UIWebview

查看:239
本文介绍了iPad:无法在UIWebview中加载Facebook页面墙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经太久了,我在努力解决这个问题。搜索很多,我决定在这里发布一个问题。



我的应用程序的作用


  1. 拍摄照片

  2. 将照片上传到网页墙壁上

  3. 在facebook上显示Facebook页面墙 UIWebview 上传完成

一切都按预期工作4几天后:)突然出现问题:(



代码

  NSString * facebookPageURL = @https://m.facebook.com/pages/<myPageName>/<myPageID>?v=wall
UIWebView * webView = [[UIWebView alloc] initWithFrame:kAppFrame];
[webView setUserInteractionEnabled:NO];
[webView setBackgroundColor:[UIColor clearColor]];
webView.delegate = self;
[webView setHidden:YES];

NSURL * url = [NSURL URLWithString:[facebookPageURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] rela tiveToURL:[NSURL URLWithString:@http://login.facebook.com]];
NSMutableURLRequest * request = nil;

if(url)
request = [NSMutableURLRequest requestWithURL:url];
[webView loadRequest:request];
[self.view addSubview:webView];
[webView reload];
[self.view bringSubviewToFront:webView];
webView = nil;

场景


  1. 如果我在 iOS模拟器中的Safari中打开url facebookPageURL / li>
  2. 如果我在Mac上的任何浏览器中打开该网址,都可以正常工作

  3. webView 请参阅白屏

  4. 如果我更改了 facebookPageURL 以删除?v =墙?v = info 我可以看到页面(不是空白屏幕至少)。

注意
1.我的Facebook页面不是未发布的和是可见的
2.我已经交叉检查了Facebook页面的权限。



我怀疑Facebook一夜之间有变化。



请指导。

解决方案

似乎有史以来反复无常的 Facebook 已经取消了查看墙的权限。我得出这个结论,当我在单独的项目中尝试相同的事情时,我得到了信息照片,但是对于,它变成灰色



所以在这个问题上,遇到或可能受苦的解决方案就是这个问题。





{id:< imge_id>,post_id:< post_id& }



http://www.facebook.com/photo.php? fbid =< imge_id>



它的作用就像一个魅力。



编辑:1
刚才我想出了一个问题
对于具有年龄限制的页面,我们需要验证哪个SSO不支持UIWebView我的应用程序。



我不得不降级到不再使用SSO。而现在它的工作,无论什么。



只是添加这里,你可以找到如何整齐地降级到 non-sso 机制。


Its already too long i am struggling with this issue. After searching a lot I decided to post a question here.

What my app does

  1. Captures photo
  2. Uploads the photo on the wall of the page
  3. Displays the facebook page wall in a UIWebview after upload is complete

Everything was working as expected 4 days back :) Suddenly something went wrong :(

Code

    NSString *facebookPageURL =@"https://m.facebook.com/pages/<myPageName>/<myPageID>?v=wall"
    UIWebView *webView = [[UIWebView alloc] initWithFrame:kAppFrame];
    [webView setUserInteractionEnabled:NO];
    [webView setBackgroundColor:[UIColor clearColor]];
    webView.delegate = self;
    [webView setHidden: YES];

    NSURL *url = [NSURL URLWithString:[facebookPageURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] relativeToURL:[NSURL URLWithString:@"http://login.facebook.com"]];
    NSMutableURLRequest *request = nil;

    if(url)
        request = [NSMutableURLRequest requestWithURL:url];        
       [webView loadRequest:request];
    [self.view addSubview:webView];
    [webView reload];
    [self.view bringSubviewToFront:webView];
    webView = nil;

Scenario

  1. If I open the url facebookPageURL in Safari in iOS Simulator it works well
  2. If I open the url in any browser on Mac it works well
  3. In webView I see a white screen
  4. If I change the facebookPageURL to remove ?v=wall to ?v=info I am stil able to see the page.(not blank screen atleast).

Note 1. My facebook Page is NOT unpublished and is visible. 2. I have cross checked the facebook page permissions.

I suspect there is something changed on facebook side overnight.

Please guide.

解决方案

It seems the ever capricious Facebookhas removed the permission to view the wall. I came to this conclusion as when I tried the same thing in separate project I was getting both info and photos but for wall it turned grey

So Here the solution for al those suffering or might suffer form this issue.

I am getting a dictionary in response to the post

{"id":"<imge_id>","post_id":"<post_id>"}

http://www.facebook.com/photo.php?fbid=<imge_id>

and it works like a charm.

Edit:1 Just now I figured out an issue For the pages with an age restriction, we need to authenticate which SSO doesn't supports for UIWebView inside my app.

I had to downgrade to NOT using SSO anymore. And now it works no matter what.

Just to add here you can find how to neatly downgrading to non-sso mechanism.

这篇关于iPad:无法在UIWebview中加载Facebook页面墙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆