gpt4 book ai didi

ios - Facebook 好友请求对话框停止在 UIWebView 上工作

转载 作者:行者123 更新时间:2023-11-28 18:39:53 24 4
gpt4 key购买 nike

我使用 stackoverflow 上的帖子在 iPhone 上实现了“添加 friend ”对话框:
Facebook friends dialog returns "Unknown method" error ,它是为 Android 实现的,但很容易转换为 iPhone。

直到几天前它停止工作之前它一直运行良好,现在它向我抛出一个错误:

HitMe 发生错误。请稍后再试。
API 错误代码:3
API错误描述:未知方法
错误消息:此显示类型不支持此方法

我尝试在 facebook roadmap 中搜索:https://developers.facebook.com/roadmap/ 但找不到任何提及更改的内容,有没有人遇到过这个问题或知道在 iPhone 上实现“好友请求”对话框的另一种方法?

这是我为实现“好友请求”对话框而对 Facebook 2.0 sdk 所做的更改:

在Facebook.m中的dialog:andParams:andDelegate:方法中我将原来的代码替换为如下代码:

-(void)dialog:(NSString *)action
andParams:(NSMutableDictionary *)params
andDelegate:(id <FBDialogDelegate>)delegate {

[_fbDialog release];

NSString *dialogURL;

if ([action isEqualToString:kFriends])
{
dialogURL = [kDialogBaseURLForFriends stringByAppendingString:action];
}
else
{
dialogURL = [kDialogBaseURL stringByAppendingString:action];
}

if ([action isEqualToString:kFriends])
{
[params setObject:@"popup" forKey:@"display"];
}
else
{
[params setObject:@"touch" forKey:@"display"];
}

[params setObject:kSDKVersion forKey:@"sdk"];
[params setObject:kRedirectURL forKey:@"redirect_uri"];

if ([action isEqualToString:kLogin]) {
[params setObject:@"user_agent" forKey:@"type"];
_fbDialog = [[FBLoginDialog alloc] initWithURL:dialogURL loginParams:params delegate:self];
} else {
[params setObject:_appId forKey:@"app_id"];
if ([self isSessionValid]) {
[params setValue:[self.accessToken stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
forKey:@"access_token"];
[self extendAccessTokenIfNeeded];
}

// by default we show dialogs, frictionless cases may have a hidden view
BOOL invisible = NO;

// frictionless handling for application requests
if ([action isEqualToString:kApprequests]) {
// if frictionless requests are enabled
if (self.isFrictionlessRequestsEnabled) {
// 1. show the "Don't show this again for these friends" checkbox
// 2. if the developer is sending a targeted request, then skip the loading screen
[params setValue:@"1" forKey:@"frictionless"];
// 3. request the frictionless recipient list encoded in the success url
[params setValue:@"1" forKey:@"get_frictionless_recipients"];
}

// set invisible if all recipients are enabled for frictionless requests
id fbid = [params objectForKey:@"to"];
if (fbid != nil) {
// if value parses as a json array expression get the list that way
SBJsonParser *parser = [[[SBJsonParser alloc] init] autorelease];
id fbids = [parser objectWithString:fbid];
if (![fbids isKindOfClass:[NSArray class]]) {
// otherwise seperate by commas (handles the singleton case too)
fbids = [fbid componentsSeparatedByString:@","];
}
invisible = [self isFrictionlessEnabledForRecipients:fbids];
}
}

_fbDialog = [[FBDialog alloc] initWithURL:dialogURL
params:params
isViewInvisible:invisible
frictionlessSettings:_frictionlessRequestSettings
delegate:delegate];
}

[_fbDialog show];

其中 kFriends 是@"friends",kDialogBaseURLForFriends 是@"https://facebook.com/dialog/"

最佳答案

适用于 IOS6。

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if ([(NSMutableURLRequest *)request respondsToSelector:@selector(setValue:forHTTPHeaderField:)]) {
[(NSMutableURLRequest *)request setValue:@" Safari/537.1" forHTTPHeaderField:@"User_Agent"];
}
}

关于ios - Facebook 好友请求对话框停止在 UIWebView 上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12334018/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com