iOS - Unable to Upload media with Twitter/Fabric New SDK

后端 未结 4 1714
面向向阳花
面向向阳花 2021-02-06 12:52

I want to post a photo to twitter from my iOS app. I can post a tweet without media but when i am trying to attach media it throws an error.

I am following twitter docu

4条回答
  •  我在风中等你
    2021-02-06 13:24

    Completing the Saani's answer

    // Post tweet With media_id
    
    mediaID = [json objectForKey:@"media_id_string"];
    client = [[Twitter sharedInstance] APIClient];
    message = @{@"status": title, @"wrap_links": @"true", @"media_ids": mediaID};
    
    NSURLRequest *request = [client URLRequestWithMethod:@"POST" URL:@"https://api.twitter.com/1.1/statuses/update.json" parameters:message error:&error];
    
    [client sendTwitterRequest:request completion:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
    
        if (connectionError) {
            NSLog(@"error %@",[connectionError localizedDescription]);
        } else {
            NSError *jsonError;
            NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];
            NSLog(@"json Finish! %@",json);
        }
    }];
    

提交回复
热议问题