gpt4 book ai didi

objective-c - IOS Facebook SDK登录后无法获取用户信息

转载 作者:太空狗 更新时间:2023-10-30 03:55:20 25 4
gpt4 key购买 nike

好吧,我正在为从 Facebook IOS SDK (3.1.1) 获取一些基本用户信息而苦恼。在使用其他平台进行 FB 开发后,我非常确信我的问题与 FB 应用程序的设置有关,而不是与我的代码有关。顺便说一句,我在 iTunes 中并为 iPhone 设置了一个 iTunes ID。我还根据我的 bundle ID 仔细检查并四次检查了应用程序中的 bundle ID。

现在我可以对测试用户进行身份验证并获取所有详细信息等。效果很好。当我以像我这样的真实用户身份登录时(我是该项目的开发人员),我得到了一个 Auth token ,但是获取用户的调用失败了,我不确定我做错了什么(如果它适用于作为测试用户,它应该适用于所有人)。

我只需要从用户那里得到,顺便说一句,就是他们的名字、姓氏、FB 用户 ID 和电子邮件地址(可选,但需要)。

目前在使用 games tutorial 进行身份验证后.登录后,我会执行以下操作(尽管我做了很多其他事情,结果相同):

 - (void)fbDidLogin
{
// removed the setup for the class level Facebook var that I am currently not using

// get information about the currently logged in user

NSString *fql = @"select uid, first_name, last_name, email from user where uid = me()";
NSDictionary *queryParam = [NSDictionary dictionaryWithObjectsAndKeys:fql, @"q", nil];

[FBRequestConnection startWithGraphPath:@"/fql"
parameters:queryParam
HTTPMethod: @"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
[self meRequestResult:result WithError:error];
}];
}

meRequestResult 例程是这样开始的:

- (void)meRequestResult:(id)result WithError:(NSError *)error
{
if ([result isKindOfClass:[NSDictionary class]])
{
NSDictionary *dictionary;
if([result objectForKey:@"data"])
dictionary = (NSDictionary *)[(NSArray *)[result objectForKey:@"data"] objectAtIndex:0];
else
dictionary = (NSDictionary *)result;

[fbUserData release];
fbUserData = [dictionary retain];

NSString *facebookId = [dictionary objectForKey:@"id"];
if(!facebookId)
facebookId = [dictionary objectForKey:@"uid"];
// and more follows that is not pertinent

当我在 FB IOS SDK 中打开请求日志记录时。我看到了同样的东西,但在任何地方都找不到这些是什么意思的描述。

这是日志中的最后 10 行左右:

 2012-12-03 11:52:12.394 mTender[6572:1cd03] Reachability Flag Status: -R -----l- networkStatusForFlags
2012-12-03 11:52:12.395 mTender[6572:1cd03] The internet is working via WIFI.
2012-12-03 11:52:12.396 mTender[6572:1cd03] Reachability Flag Status: -R ------- networkStatusForFlags
2012-12-03 11:52:12.396 mTender[6572:1cd03] A gateway to the host server is working via WIFI.
2012-12-03 11:52:35.093 mTender[6572:1cd03] FBSDKLog: Request <#1111>:
URL: https://graph.facebook.com//fql?sdk=ios&access_token=ACCESS_TOKEN_REMOVED&q=select%20uid%2C%20first_name%2C%20last_name%2C%20email%20%20from%20user%20where%20uid%20%3D%20me%28%29&migration_bundle=fbsdk%3A20121003&format=json
Method: GET
UserAgent: FBiOSSDK.3.1.1
MIME: multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f

2012-12-03 11:52:37.194 mTender[6572:1cd03] Error: HTTP status code: 500
2012-12-03 11:52:37.196 mTender[6572:1cd03] FBSDKLog: Response <#1111> <Error>:
The operation couldn’t be completed. (com.facebook.sdk error 5.)

希望有人能解决这个问题。这是该项目的最后一步..

最佳答案

我正在做与您非常相似的事情。我正在使用 Facebook 登录,这样我就不必担心存储密码之类的问题。

我关注了this一套说明.. facebook 网站的布局方式似乎很糟糕,到处都是过时的东西。

您可以使用 native Facebook 或基于网络的用户身份验证(SDK 将管理所有这些),因此它可以在旧版本的 iOS 上运行,并且在未登录 native Facebook 时也能正常工作。

您将设置一个处理程序,它将为您提供一个“NSDictionary *user”,其中包含您需要的所有内容。无需在 iphone 客户端上使用 graph api。

关于objective-c - IOS Facebook SDK登录后无法获取用户信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13688501/

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