我想要一个Facebook页面,但我收到了这个错误:
{“error”:{“message”:“(#200)权限错误”,“类型”:“OAuthException”,“code”:200}}
正如您在我的代码中看到的那样,权限似乎没问题。请注意,当我想要像www.google.com这样的简单网址时,它会有效!
只有当我想要一个Facebook页面时才会出现此错误。
这是我的代码:
-(IBAction) buttonTestRecoFB
{
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"publish_actions",@"publish_stream",
nil];
[FBSession.activeSession closeAndClearTokenInformation];
[FBSession openActiveSessionWithPermissions:permissions allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// session might now be open.
[self sessionStateChanged:session state:status error:error];
}];
}
// FACEBOOK
//
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState) state
error:(NSError *)error
{
switch (state)
{
case FBSessionStateOpen:
{
NSLog(@"FBSessionStateOpen");
if (session.isOpen)
{
FBRequest *me = [FBRequest requestForMe];
[me startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary<FBGraphUser> *my,
NSError *error) {
NSLog(@"firtname = %@" , my.first_name);
/////////////////////////////////////////////////
NSString *theWholeUrl = [NSString stringWithFormat:@"https://graph.facebook.com/313449204401/likes?access_token=%@", session.accessToken];
NSLog(@"TheWholeUrl: %@", theWholeUrl);
NSURL *facebookUrl = [NSURL URLWithString:theWholeUrl];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:facebookUrl];
[req setHTTPMethod:@"POST"];
NSURLResponse *response;
NSError *err;
NSData *responseData = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&err];
NSString *content = [NSString stringWithUTF8String:[responseData bytes]];
NSLog(@"responseData: %@", content);
/////////////////////////////////////////////////
}];
}
}
答案 0 :(得分:1)
无法以编程方式将“喜欢”操作应用于Facebook页面。这在the documentation中说明:
对于未与Facebook集成的Facebook页面或网站 身份验证,开发人员应继续使用Like按钮 社交插件。