【问题标题】:Posting user profile pic to twitter giving Error 131将用户个人资料图片发布到 Twitter 给出错误 131
【发布时间】:2013-12-07 03:22:10
【问题描述】:

在尝试将用户个人资料图片发布到 twitter 时,我收到错误代码 131 响应:

2013-12-06 19:17:29.854 Tweetly[8131:60b] {
    errors =     (
                {
            code = 131;
            message = "Internal error";
        }
    );
}

Twitters 网站列出了这个:

“对应于 HTTP 500 - 发生未知的内部错误。”

这是我的代码:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {


    //Code for store image
    [picker dismissViewControllerAnimated:YES completion:nil];

    UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

    UIImage *scaledImage = [self imageWithImage:image convertToSize:CGSizeMake(500, 500)];
    NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(scaledImage)];

    [self uploadPictureWithData:imageData];

}


- (UIImage *)imageWithImage:(UIImage *)image convertToSize:(CGSize)size {

    UIGraphicsBeginImageContext(size);
    [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
    UIImage *destImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return destImage;

}



- (void)uploadPictureWithData:(NSData *)imageData {

    // Get the twitter feed
    NSURL *requestURL = [NSURL URLWithString:@"https://api.twitter.com/1.1/account/update_profile_image.json"];

    // Set up proper parameters
    NSMutableDictionary *timelineParameters = [[NSMutableDictionary alloc] init];
    [timelineParameters setObject:imageData forKey:@"image"];
    [timelineParameters setObject:@"1" forKey:@"skip_status"];

    // Create the Social Request
    SLRequest *postRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:requestURL parameters:timelineParameters];
    postRequest.account = self.delegate.userAccount;

    // Perform the request
    [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            // Check if we reached the reate limit
            if ([urlResponse statusCode] == 429) {

                // Rate limit reached
                // Display an alert letting the user know we have hit the rate limit

                UIAlertView *twitterAlert = [[UIAlertView alloc] initWithTitle:kRateLimitTitle
                                                                       message:kRateLimitMessage
                                                                      delegate:nil
                                                             cancelButtonTitle:@"Ok"
                                                             otherButtonTitles:nil];
                [twitterAlert show];

                return;

            }
            // Check if there was an error
            if (error) {

                NSLog(@"Error: %@", error.localizedDescription);
                return;

            }
            // Check if there is some response data
            if (responseData) {
                NSError *jsonError = nil;
                NSMutableArray *feedData = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&jsonError];
                if (!jsonError) {

                    // Check the response data

                    NSLog(@"%@", feedData);

                } else {

                    // Alert the user with the error
                    UIAlertView *twitterAlert = [[UIAlertView alloc] initWithTitle:kErrorTitle
                                                                           message:kErrorMessage
                                                                          delegate:nil
                                                                 cancelButtonTitle:@"Ok"
                                                                 otherButtonTitles:nil];
                    [twitterAlert show];


                }
            } else {

                // Alert the user with the error
                UIAlertView *twitterAlert = [[UIAlertView alloc] initWithTitle:kErrorTitle
                                                                       message:kErrorMessage
                                                                      delegate:nil
                                                             cancelButtonTitle:@"Ok"
                                                             otherButtonTitles:nil];
                [twitterAlert show];


            }


        });
    }];


}

知道问题可能是什么吗?我一开始以为是图片太大,所以我添加了将图片缩小到 500 x 500 的方法,但我得到了同样的错误。

在设备和模拟器上运行时都会发生此错误。

有没有人发现问题出在哪里或有任何额外的见解?谢谢!

【问题讨论】:

  • 您好,您遇到了 131 错误吗?当我想从 Mac 应用程序在 Twitter 上上传图片时,我遇到了同样的问题。

标签: http post twitter ios7


【解决方案1】:

在我的测试中,大于 1000x1000px 的图像不会同步缩小,会抛出 131 响应代码。不幸的是,无证。

确保图片 https://dev.twitter.com/rest/reference/post/account/update_profile_image

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-29
    • 1970-01-01
    • 2013-08-25
    • 1970-01-01
    • 2014-09-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多