Bad Authentication Data Error Code: 215


#1

I am getting this error when trying to use this: https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=onmyhonorband&count=50

The error is {“errors”:[{“message”:“Bad Authentication data”,“code”:215}]}

Here is what I’m trying to do:

#define kBgQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
#define storeURL [NSURL URLWithString: @"https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=onmyhonorband&count=50"]

#import "GRSTwitterTableViewController.h"
#import "TweetCell.h"

@interface GRSTwitterTableViewController ()

@end

@implementation GRSTwitterTableViewController
@synthesize screenName, text, retweeted, retweetCount, favCount, profileImage, screenNameArray, textArray, retweetedArray, retweetCountArray, favCountArray, profileImageArray, url;

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.title = @"Twitter";
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
    
    url = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=onmyhonorband&count=50"];
    
    dispatch_async(kBgQueue, ^{
        NSData *data = [NSData dataWithContentsOfURL:url];
        [self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:YES];
    });
}

- (void)fetchedData:(NSData *)responseData
{
    NSError *error;
    screenNameArray = [[NSMutableArray alloc]init];
    textArray = [[NSMutableArray alloc]init];
    retweetedArray = [[NSMutableArray alloc]init];
    retweetCountArray = [[NSMutableArray alloc]init];
    favCountArray = [[NSMutableArray alloc]init];
    profileImageArray = [[NSMutableArray alloc]init];
    
    NSArray *json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
    
    for (NSDictionary *item in json)
    {
        screenName = [item objectForKey:@"screen_name"];
        text = [item objectForKey:@"text"];
        retweeted = [item objectForKey:@"retweeted"];
        retweetCount = [item objectForKey:@"retweet_count"];
        favCount = [item objectForKey:@"favourites_count"];
        profileImage = [item objectForKey:@"profile_image_url_https"];
        
        [screenNameArray addObject:screenName];
        [textArray addObject:text];
        [retweetedArray addObject:retweeted];
        [retweetCountArray addObject:retweetCount];
        [favCountArray addObject:favCount];
        [profileImageArray addObject:profileImage];
    }
    [self.tableView reloadData];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [screenNameArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    TweetCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"];
    if (!cell)
    {
        [tableView registerNib:[UINib nibWithNibName:@"TweetCell" bundle:nil] forCellReuseIdentifier:@"myCell"];
        cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"];
    }
    
    cell.profileNameLabel.text = [screenNameArray objectAtIndex:indexPath.row];
    cell.tweetTextLabel.text = [textArray objectAtIndex:indexPath.row];
    
    return cell;
}

@end