ios – TWRequest performRequestWithHandler没有错误,但没有任何反应

我正在尝试在iOS 5上使用Twitter Framework进行分享
用户将选择要使用的帐户,以便应用程序将使用所选帐户进行共享.

但是whem共享传递给performRequestWithHandler什么都没发生,错误返回null

我的代码:

for (int i = 0; i < [_accountsArray count]; i++) {
//searching for a selected account
            if ([[[_accountsArray objectAtIndex:i] username] isEqualToString:[self getUserName]]) {
                actualUser = [_accountsArray objectAtIndex:i];
                TWRequest *sendTweet = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"https://upload.twitter.com/1/statuses/update_with_media.json"]
                                                            parameters:nil
                                                        requestMethod:TWRequestMethodPOST];

                [sendTweet addMultiPartData:[text dataUsingEncoding:NSUTF8StringEncoding] withName:@"status" type:@"multipart/form-data"];
                ACAccountStore *account = [[ACAccountStore alloc] init];

                [sendTweet setAccount:[account.accounts objectAtIndex:i]];
                NSLog(@"%@",sendTweet.account);

                [sendTweet performRequestWithHandler:^(NSData *responseData,NSHTTPURLResponse *urlResponse,NSError *error) {

                    NSLog(@"responseData: %@\n",responseData);
                    NSLog(@"urlResponse: %@\n",urlResponse);
                    NSLog(@"error: %@",error);

                }];
            }
        }

有人可以帮帮我吗?

谢谢

解决方法

在iOS中发送推文非常容易.昨晚我更新了我的应用程序,不再使用旧技术,而是使用新的SLComposeViewController技术.下面是我在我的应用程序中的代码片段,允许用户发送带有附加图像的推文.基本上完全相同的代码可用于发布到Facebook.请尝试使用此代码.它还应该允许用户选择他们发送推文的帐户(我也相信这个“​​默认帐户”发送设置隐藏在电话的设置中).

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
        SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
        [mySLComposerSheet setInitialText:@"Sample Tweet Text"];

        //Add the image the user is working with
        [mySLComposerSheet addImage:self.workingImage];

        //Add a URL if desired
        //[mySLComposerSheet addURL:[NSURL URLWithString:@"http://google.com"]];

        //Pop up the post to the user so they can edit and submit
        [self presentViewController:mySLComposerSheet animated:YES completion:nil];

        //Handle the event
        [mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
            switch (result) {
                case SLComposeViewControllerResultCancelled:
                    NSLog(@"Tweet Canceled");
                case SLComposeViewControllerResultDone:
                    NSLog(@"Tweet Done");
                    break;
                default:
                    break;
            }
        }];

    } else {
        //Can't send tweets,show error
        NSLog(@"User doesn't have twitter setup");
    }

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...