Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios7 在facebook上与facebook共享我的ios应用程序详细信息_Ios7_Social Framework_Slcomposeviewcontroller - Fatal编程技术网

Ios7 在facebook上与facebook共享我的ios应用程序详细信息

Ios7 在facebook上与facebook共享我的ios应用程序详细信息,ios7,social-framework,slcomposeviewcontroller,Ios7,Social Framework,Slcomposeviewcontroller,我正在我的facebook应用程序上添加共享功能。例如,当选择“说”时,会有一个按钮用于在facebook上共享该“说”。单击此按钮时,我只能在我的facebook页面上看到共享的说,没有关于我的ios应用程序的任何信息。如何让每个人都知道这句话是通过我的ios应用程序共享的?请帮帮我 我可能会晚一点。希望这有帮助 你必须使用帐户框架和社交框架与你的应用程序名共享。 首先确保你在Facebook上正确设置了你的应用程序。然后你可以使用Facebook应用程序ID通过你的应用程序共享你的帖子 下面

我正在我的facebook应用程序上添加共享功能。例如,当选择“说”时,会有一个按钮用于在facebook上共享该“说”。单击此按钮时,我只能在我的facebook页面上看到共享的说,没有关于我的ios应用程序的任何信息。如何让每个人都知道这句话是通过我的ios应用程序共享的?请帮帮我

我可能会晚一点。希望这有帮助

你必须使用帐户框架和社交框架与你的应用程序名共享。 首先确保你在Facebook上正确设置了你的应用程序。然后你可以使用Facebook应用程序ID通过你的应用程序共享你的帖子

下面是一个示例代码,向您展示了如何将Accounts框架与Social框架结合使用:

    ACAccountType * facebookAccountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

    // At first, we only ask for the basic read permission
    NSArray * permissions = @[@"email"];

    NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"275485699289493", ACFacebookAppIdKey, permissions, ACFacebookPermissionsKey, ACFacebookAudienceOnlyMe, ACFacebookAudienceKey, nil];

    NSArray *accounts = [self.accountStore accountsWithAccountType:facebookAccountType];
    //it will always be the last object with single sign on
    self.facebookAccount = [accounts lastObject];

    [self.accountStore requestAccessToAccountsWithType:facebookAccountType options:dict completion:^(BOOL granted, NSError *error) {
        if (granted && error == nil) {
            /**
             * The user granted us the basic read permission.
             * Now we can ask for more permissions
             **/
            NSArray *readPermissions = @[ @"publish_actions"];
            [dict setObject:readPermissions forKey: ACFacebookPermissionsKey];

            [self.accountStore requestAccessToAccountsWithType:facebookAccountType options:dict completion:^(BOOL granted, NSError *error) {
                if(granted && error == nil) {


                    NSDictionary *parameters = @{@"message": @"This Should Work Perfectly !! "};

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

                    SLRequest *feedRequest = [SLRequest
                                              requestForServiceType:SLServiceTypeFacebook
                                              requestMethod:SLRequestMethodPOST
                                              URL:feedURL
                                              parameters:parameters];

                    feedRequest.account = self.facebookAccount;

                    [feedRequest performRequestWithHandler:^(NSData *responseData, 
                                                             NSHTTPURLResponse *urlResponse, NSError *error)
                     {
                         // Handle response
                     }];

                } else {
                    NSLog(@"error is: %@",[error description]);
                }
            }];
        } else {
            NSLog(@"error is: %@",[error description]);
        }
    }];
}