-1

私はTwitterと統合されたアプリケーションを作成しています..ツイートにデバイスの画像を追加するボタンを作成するために何をしなければならないかを知りたいと思っていました.また、それを使用するフレームワークと、私のアプリはios4とも互換性があるはずなので、コード。

まず、ios5より前のtwitterで画像を送信することは可能ですか?

4

3 に答える 3

1

use sharekit. Refer ShareKit link.

于 2012-11-19T05:32:22.400 に答える
1
  1. はい、Twitterに画像をアップロードできます。
  2. アプリケーションへの Twitter の統合に関するこのブログ記事をご覧ください。と
  3. これは、アプリケーションに twitpic を追加して画像をアップロードする方法に関するものです
于 2012-11-19T10:01:52.510 に答える
0

この送信には Oauth を使用できます。ios4 と互換性があります。acct123 は Oauth アカウントです。

- (IBAction)composeTweet:(id)sender
{
   // Build a twitter request
NSString *resultprofileUrl= [NSString stringWithFormat:@"https://api.twitter.com/1/statuses/update.json"];

tweets = [NSMutableArray array];


// Posting image and text to twitpic............


ASIFormDataRequest *req = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:@"http://api.twitpic.com/2/upload.json"]];
[req addRequestHeader:@"X-Auth-Service-Provider" value:@"https://api.twitter.com/1/account/verify_credentials.json"];

[req addRequestHeader:@"X-Verify-Credentials-Authorization"
                value:[acct123 oAuthHeaderForMethod:@"GET"
                                             andUrl:@"https://api.twitter.com/1/account/verify_credentials.json"
                                          andParams:nil]];

[req setData:UIImageJPEGRepresentation(imageview3.image, 0.8) forKey:@"media"];
[req setPostValue:@"YourKey" forKey:@"key"];
[req setPostValue:tweetPost.text forKey:@"message"];
[req startSynchronous];
NSLog(@"Got HTTP status code from TwitPic: %d", [req responseStatusCode]); 
NSLog(@"Response string: %@", [req responseString]);
NSDictionary *twitpicResponse = [[req responseString] JSONValue];
NSLog(@"image url: %@", twitpicResponse);
url1 = [twitpicResponse valueForKey:@"url"];
NSLog(@"url=%@",url1);
if (url1 == nil) {
    url1 = @"";
}
[req release];
NSString *resultUrl = [[NSString alloc]init];
if(reply_tweet_flag != 1)
{
    resultUrl = [NSString stringWithFormat:@"%@ %@",tweetPost.text,url1];
}
else
{
    resultUrl= [NSString stringWithFormat:@"%@",tweetPost.text];
}
NSLog(@"URL>>>>%@",resultUrl);
NSString *postUrl = @"https://api.twitter.com/1/statuses/update.json";
ASIFormDataRequest *request = [[ASIFormDataRequest alloc]
                               initWithURL:[NSURL URLWithString:postUrl]];

NSMutableDictionary *postInfo = [NSMutableDictionary
                                 dictionaryWithObject:resultUrl
                                 forKey:@"status"];


for (NSString *key in [postInfo allKeys]) {
    [request setPostValue:[postInfo objectForKey:key] forKey:key];
}

[request addRequestHeader:@"Authorization"
                    value:[acct123 oAuthHeaderForMethod:@"POST"
                                                 andUrl:postUrl
                                              andParams:postInfo]];

[request startSynchronous];

NSLog(@"Status posted. HTTP result code: %d", request.responseStatusCode);


if (reply_tweet_flag == 1) {
    reply_tweet_flag = 0;
    [self refresh];

}
if([tweetPost.text isEqualToString:@""])
{
    UIAlertView *message1 = [[UIAlertView alloc] initWithTitle:@""
                                                       message:@"Check the message"
                                                      delegate:self
                                             cancelButtonTitle:@"OK"
                                             otherButtonTitles: nil];
    [message1 show];
    message1.tag=1;

}
else{
    [tweetPost setText:@""];
    imageview3.image = [UIImage imageNamed:@""];

    UIAlertView *message1 = [[UIAlertView alloc] initWithTitle:@""
                                                       message:@"Post was send succesfully"
                                                      delegate:self
                                             cancelButtonTitle:@"OK"
                                             otherButtonTitles: nil];
    [message1 show];
    message1.tag=1;
}

}

于 2012-11-19T07:43:31.870 に答える