我正以这种方式尝试,它不会进入shareTW方法中的成功块,并且得到一个类似于“错误创建状态”的错误--我遵循了一些教程,但不幸的是,它们是无助的。
-(IBAction)Btn_TwitterImgButton:(Id)发件人
{
UIImageView *tweetimage=[[UIImageView alloc]init];
if (isTwitter == NO)
{
tweetimage.image=[UIImage imageNamed:@"twitter_on.png"];
[self postTWDetails];
}
else if (isTwitter==YES)
{
twitterString = @"";
isTwitter = NO;
tweetimage.image=[UIImage imageNamed:@"twiter@2x.png"];
}}
-(IBAction)Tweet Button:(id)sender{
if ([twitterString isEqualToString:@"twitter loggedin"])
{
STTwitterAPI *twitter = [STTwitterAPI twitterAPIOSWithFirstAccount];
[twitter verifyCredentialsWithSuccessBlock:^(NSString *username)
{
// [self postTWDetails];
}
errorBlock:^(NSError *error)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Twitter Accounts" message:@"There are no Twitter accounts configured. You can add a Twitter account in your phone's Settings." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
}];
[self sharetoTW];
}}-postTWDetails{ twitterString = @"twitter loggedin";
isTwitter = YES;}
-(void)sharetoTW {
NSString *Str=self.tweetTextView text;NSLog(@Str%@,Str);
NSLog(@"tweetTextView text %@",self.tweetTextView.text);
STTwitterAPI *twitter = [STTwitterAPI twitterAPIOSWithFirstAccount];
[twitter verifyCredentialsWithSuccessBlock:^(NSString *username)
{
[twitter postStatusUpdate:Str inReplyToStatusID:nil mediaURL:[NSURL URLWithString:@"https://www.google.com"] placeID:nil latitude:nil longitude:nil successBlock:^(NSDictionary *status)
{
NSLog(@"Success block");
}
errorBlock:^(NSError *error)
{
NSLog(@"str %@",Str);
NSLog(@"error ====%@",[error localizedDescription]);
}];
}
errorBlock:^(NSError *error)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Twitter Accounts" message:@"There are no Twitter accounts configured. You can add a Twitter account in your phone's Settings." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
}];}
发布于 2014-12-03 06:36:34
我刚刚在-(无效)sharetoTW中更改了post方法,并且工作很好..!
-(void)sharetoTW
{
NSString *Str=[self.placeholdertextview text];
NSLog(@"str %@",Str);
NSLog(@"placeholder text %@",self.placeholdertextview.text);
STTwitterAPI *twitter = [STTwitterAPI twitterAPIOSWithFirstAccount];
dispatch_async(dispatch_get_main_queue(), ^{
[twitter verifyCredentialsWithSuccessBlock:^(NSString *username)
{
[twitter postStatusUpdate:Str
inReplyToStatusID:nil
latitude:nil
longitude:nil
placeID:nil
displayCoordinates:nil
trimUser:nil
successBlock:^(NSDictionary *status)
{
NSLog(@"Success Block");
}
errorBlock:^(NSError *error)
{
NSLog(@"error ====%@",[error localizedDescription]);
}];
}
errorBlock:^(NSError *error)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Twitter Accounts" message:@"There are no Twitter accounts configured. You can add a Twitter account in your phone's Settings." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
}];
});
}https://stackoverflow.com/questions/27264423
复制相似问题