无法与Facebook共享Feed

时间:2014-06-04 14:32:48

标签: ios objective-c facebook-graph-api ios7

在我的申请中,我无法与Facebook分享Feed。我得到(#200)用户没有授权应用程序执行此操作错误。 我的代码是:

 dispatch_async(dispatch_get_main_queue(), ^{

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/me/feed"]];

    asiRequest = [ASIFormDataRequest requestWithURL:url];

    [asiRequest setRequestMethod:@"POST"];

     NSString *link =[NSString stringWithFormat:@"%@",@"https://www.google.co.in/?gfe_rd=cr&ei=sf-OU6rULoyBoAOk8YHADg"];

    //[asiRequest setPostValue:fbtextView.text forKey:@"message"];
    [asiRequest setPostValue:link forKey:@"link"];
    [asiRequest setPostValue:acessToken  forKey:@"access_token"];
    [asiRequest setPostValue:@"testing" forKey:@"name"];
    [asiRequest setPostValue:[NSString stringWithFormat:@"%@",@"https://s3-us-west-2.amazonaws.com/wonup-akiajjcm7taqsdtarnda/WonUp06-03-2014-12-14-PM.jpeg"] forKey:@"picture"];

    [asiRequest setDelegate:self];
    [asiRequest startAsynchronous];
});

我也使用FBWebDialog代码:

NSMutableDictionary *params1;

params1 = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"testing", @"name",@"356993987780240",@"app_id",acessToken,@"access_token",link,@"link", nil];

dispatch_sync(dispatch_get_main_queue(), ^(void){

    [FBWebDialogs presentFeedDialogModallyWithSession:nil parameters:params1 handler:
     ^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
     {
         // NSLog(@"result ======%@",resultURL);
         if (error)
         {
             //  NSLog(@"error ======%@",error);
         }
         else
         {
             if (result == FBWebDialogResultDialogNotCompleted)
             {
                 // NSLog(@"User canceled story publishing.");
             }
             else
             {
                 NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
                 if (![urlParams valueForKey:@"post_id"])
                 {
                     // NSLog(@"User canceled story publishing.");
                 }
                 else
                 {
                     double delayInSeconds = 0.5;
                     dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
                     dispatch_after(popTime, dispatch_get_main_queue(), ^(void){

                         UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"WonUp" message:[NSString stringWithFormat:@"You are successfully Posted"] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

                         [alertView show];

                     });

                 }
             }
         }
     }];

});

它扼杀了我的时间。请把你的建议和代码告诉我。提前致谢

0 个答案:

没有答案