Ios TWRequest performRequestWithHandler没有错误,但什么也没有发生
我正在尝试在iOS 5上使用Twitter框架进行共享 用户将选择要使用的帐户,因此应用程序将使用所选帐户进行共享 但是当共享传递给Ios TWRequest performRequestWithHandler没有错误,但什么也没有发生,ios,twitter,request,twrequest,Ios,Twitter,Request,Twrequest,我正在尝试在iOS 5上使用Twitter框架进行共享 用户将选择要使用的帐户,因此应用程序将使用所选帐户进行共享 但是当共享传递给performRequestWithHandler时,不会发生错误返回null 我的代码: for (int i = 0; i < [_accountsArray count]; i++) { //searching for a selected account if ([[[_accountsArray objectAtIndex:i
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);
}];
}
}
for(int i=0;i<[u accountsArray count];i++){
//搜索所选帐户
if([[[u accountsArray objectAtIndex:i]用户名]IseQualtString:[self-getUserName]]){
实际值=[\u accountsArray objectAtIndex:i];
TWRequest*sendTweet=[[TWRequest alloc]initWithURL:[NSURL URLWithString:@]https://upload.twitter.com/1/statuses/update_with_media.json"]
参数:零
requestMethod:TWRequestMethodPOST];
[sendTweet addMultiPartData:[text-dataUsingEncoding:NSUTF8StringEncoding],名称:@“status”类型:@“multipart/form data”];
ACAccountStore*account=[[ACAccountStore alloc]init];
[sendTweet setAccount:[account.accounts objectAtIndex:i]];
NSLog(@“%@”,sendTweet.account);
[sendTweet performRequestWithHandler:^(NSData*responseData,NSHTTPURLRResponse*URLRResponse,NSError*错误){
NSLog(@“responseData:%@\n”,responseData);
NSLog(@“urresponse:%@\n”,urresponse);
NSLog(@“错误:%@”,错误);
}];
}
}
有人能帮我吗
谢谢现在用iOS发送推文非常容易。昨晚我更新了我的应用程序,不再使用旧技术,而是使用新的SLComposeViewController技术。下面是我的应用程序中的一段代码,允许用户发送带有附加图像的tweet。基本上,相同的代码可以用来发布到facebook。请尝试改用此代码。它还应该允许用户选择他们发送推文的账号(我也相信这个“默认账号”发送设置隐藏在手机的某个地方)
这也开始发生在我身上。出于某种原因,在iPodtouch iOS5上它可以正常工作,但在iPhone4iOS6上却不能。检查URL是否正确:
https://api.twitter.com/1.1/statuses/update_with_media.json
vs.https://upload.twitter.com/1/statuses/update_with_media.json
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");
}