Facebookページが好きですが、次のエラーが発生しました。
{"error":{"message": "(#200)パーミッションエラー"、 "type": "OAuthException"、 "code":200}}
私のコードでわかるように、権限は問題ないようです。www.google.comのような単純なURLが好きな場合は、機能することに注意してください。
このエラーが発生したのは、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);
/////////////////////////////////////////////////
}];
}
}