简体   繁体   English

从iPhone SDK调用Facebook API方法

[英]Calling Facebook API method from iPhone SDK

I got Facebook Connect working and all and it's loading up the user's friends list with perfection. 我让Facebook Connect正常工作,并且一切都非常完美地加载了用户的朋友列表。 So now I have the logged in user's UID and the friend's UID. 因此,现在我具有登录用户的UID和朋友的UID。 How would I go about calling their users.getInfo method from the SDK? 我将如何从SDK调用他们的users.getInfo方法? The example below is what they give me to set a status, but I don't know how I can transform it to work with what I need. 下面的示例是他们给我设置状态的条件,但是我不知道如何将其转换为适合我需要的状态。 Especially the NSDictionary part. 特别是NSDictionary部分。 Please help! 请帮忙!

Example Code - 示例代码-

NSString *statusString = exampleTextField.text;
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                           statusString, @"status",
                           @"true", @"status_includes_verb",
                           nil];
[[FBRequest requestWithDelegate:self] call:@"facebook.Users.setStatus" params:params];

Thanks for any help! 谢谢你的帮助!

According to the documentation at http://github.com/facebook/facebook-iphone-sdk you have to use the old API calls and the Facebook Query Language (fql) to pull information via the SDK. 根据http://github.com/facebook/facebook-iphone-sdk上的文档,您必须使用旧的API调用和Facebook查询语言(fql)才能通过SDK提取信息。 So you'd have to identify what information you want (or pull in a bunch and separate). 因此,您必须确定所需的信息(或将它们分开收集)。

Here's the example they give to pull a user's name. 这是他们提供的拉用户名称的示例。

- (void)getUserName {
    NSString* fql = @"select name from user where uid == 1234";
    NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
    [[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
}
- (void)request:(FBRequest*)request didLoad:(id)result {
    NSArray* users = result;
    NSDictionary* user = [users objectAtIndex:0];
    NSString* name = [user objectForKey:@"name"];
    NSLog(@"Query returned %@", name);
}

getUserName shows you the data pull which you could adapt to create new routines--but the request:didLoad: function would need some internal switching. getUserName向您显示了您可以用来创建新例程的数据提取-但是request:didLoad:函数将需要一些内部切换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM