我有一个名为FBSession
的会话类型。我知道会话是开放的,但是如何发送图形请求来创建事件,然后邀请用户参加该事件?我知道用户的Facebook ID,因为我设法从本地地址簿属性中提取它们。
if (appDelegate.session.state == FBSessionStateCreatedTokenLoaded) {
// even though we had a cached token, we need to login to make the session usable
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
switch (status) {
case FBSessionStateOpen:
{
/* What do I do here to create the event and invite IDs x, y and z where z, y and z are long long Facebook Ids */
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"venue name",@"name",
@"2012-01-13T17:00:00+0000",@"start_time",
@"2012-01-16T01:30:00+0000",@"end_time",@"location",@"location name ch",@"1234567890",@"id", nil];
FBRequest *facebook = [[FBRequest alloc] initWithSession:appDelegate.session graphPath:@"me/events" parameters:params HTTPMethod:@"POST"];
这是否正确,我需要运行哪些委托方法来检查它是否在appDelegate中正常工作?
答案 0 :(得分:0)
好的,这看起来很酷。
FBRequest *eventPostOK = [FBRequest requestWithGraphPath:@"me/permissions" parameters:Nil HTTPMethod:GET];
[eventPostOK startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
BOOL canDoIt = FALSE;
if (!error)
{
FBGraphObject *data = [result objectForKey:@"data"];
for(NSDictionary<FBGraphObject> *aKey in data) {
canDoIt = [[aKey objectForKey:@"create_event"] boolValue];
}
}
if (canDoIt) { ... DO STUFF .... }
];