我正在尝试使用Facebook在我的应用程序中签入,我创建了故事,动作和对象类型。 Facebook给了我代码:
NSMutableDictionary<FBGraphObject> *object =
[FBGraphObject openGraphObjectForPostWithType:@"restaurant.restaurant"
title:@"Sample Restaurant"
image:@"https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png"
url:@"http://samples.ogp.me/440002909390231"
description:@"This place rocks"];;
[FBRequestConnection startForPostWithGraphPath:@"me/objects/restaurant.restaurant"
graphObject:object
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
// handle the result
}];
但它不起作用。
我也尝试过了:
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
@"302184056577324", @"fb:app_id",
@"restaurant.restaurant", @"og:type",
@"http://samples.ogp.me/440002909390231", @"og:url",
@"Sample Restaurant", @"og:title",
@"https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png", @"og:image",
@"This place rocks", @"og:description",
@"1601 Willow Rd.", @"restaurant:contact_info:street_address",
@"Menlo Park", @"restaurant:contact_info:locality",
@"California", @"restaurant:contact_info:region",
@"94025", @"restaurant:contact_info:postal_code",
@"United States", @"restaurant:contact_info:country_name",
@"brian@example.com", @"restaurant:contact_info:email",
@"212-555-1234", @"restaurant:contact_info:phone_number",
@"http://www.facebook.com", @"restaurant:contact_info:website",
@"37.484828", @"place:location:latitude",
@"-122.148283", @"place:location:longitude",
nil
];
/* make the API call */
[FBRequestConnection startWithGraphPath:@"me/myapp:check_in"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
DBLog(@"result: %@", result);
DBLog(@"error: %@", error);
}];
}
这两个代码都不起作用,有人可以帮助我吗?
由于
答案 0 :(得分:2)
试试这个
[FBRequestConnection startForPostStatusUpdate:message
place:placeId
tags:nil
completionHandler:
^(FBRequestConnection *connection, id result, NSError *error) {
NSLog(@"Response....... \n\n %@ %@ %@",connection,result,error);
}
];
答案 1 :(得分:0)
我发现了这种方式:
[FBSession openActiveSessionWithPublishPermissions:@[@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceEveryone
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
if (FBSession.activeSession.isOpen && !error) {
// specify that this Open Graph object will be posted to Facebook
object.provisionedForPost = YES;
// Post custom object
[FBRequestConnection startForPostOpenGraphObject:object completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
// create an Open Graph action
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:[result objectForKey:@"id"] forKey:@"establishment"];
// create action referencing user owned object
[FBRequestConnection startForPostWithGraphPath:@"/me/myapp:check_in" graphObject:action completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(!error) {
success();
}else{
failure(error);
}
}];
}];
}
}];
但我要将行动地方更改为自定义机构,这样会在用户的时间轴上发布两次简单帖子,其他签入
这是有效的,但不是100%正确。