Iphone 在ios 5&;的twitter上上传图片而不打开Tweetsheet;ios 6
我想在ios5和ios6中上传图片而不打开Tweetsheet。 可能吗? 我曾尝试使用TweetSheet上传照片,我可以上传照片,但不打开TweetSheet就无法上传照片 已使用:-tweetComposeViewController 请告诉我怎么做 如果(appDelegate.PHONE\u OS>=5),请提前感谢Iphone 在ios 5&;的twitter上上传图片而不打开Tweetsheet;ios 6,iphone,ios,ios5,twitter,ios6,Iphone,Ios,Ios5,Twitter,Ios6,我想在ios5和ios6中上传图片而不打开Tweetsheet。 可能吗? 我曾尝试使用TweetSheet上传照片,我可以上传照片,但不打开TweetSheet就无法上传照片 已使用:-tweetComposeViewController 请告诉我怎么做 如果(appDelegate.PHONE\u OS>=5),请提前感谢 if (appDelegate.PHONE_OS >= 5) { NSString *strTwitterMessage; strT
if (appDelegate.PHONE_OS >= 5)
{
NSString *strTwitterMessage;
strTwitterMessage = [NSString stringWithFormat:@"test twitter post : Photo link URL "];
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {
if(granted) {
// Get the list of Twitter accounts.
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
NSLog(@"Count : %d",[accountsArray count]);
ACAccount *twitterAccount;
int flagTwitter;
flagTwitter = 0;
for(int i = 0;i<[accountsArray count];i++)
{
if([[[accountsArray objectAtIndex:i]username] isEqualToString:appDelegate.strTwitterEmailSelected])
{
flagTwitter = 1;
twitterAccount = [accountsArray objectAtIndex:i];
}
}
if(flagTwitter == 1)
{
appDelegate.strTwitterEmail = appDelegate.strTwitterEmailSelected;
}
else
{
appDelegate.strTwitterEmail = [[accountsArray objectAtIndex:0]username];
twitterAccount = [accountsArray objectAtIndex:0];
}
//ACAccount *twitterAccount = [accountsArray objectAtIndex:0];
//appDelegate.strTwitterEmail = [[accountsArray objectAtIndex:0]username];
UIImage *image =[UIImage imageNamed:@"image.png"];
NSURL *url =
[NSURL URLWithString:
@"https://upload.twitter.com/1/statuses/update_with_media.json"];
// Create a POST request for the target endpoint
TWRequest *request =
[[TWRequest alloc] initWithURL:url
parameters:nil
requestMethod:TWRequestMethodPOST];
[request setAccount:twitterAccount];
NSData *imageData = UIImagePNGRepresentation(image);
[request addMultiPartData:imageData
withName:@"media[]"
type:@"multipart/form-data"];
NSString *status = strTwitterMessage;
[request addMultiPartData:[status dataUsingEncoding:NSUTF8StringEncoding]
withName:@"status"
type:@"multipart/form-data"];
[request performRequestWithHandler:
^(NSData *responseData1, NSHTTPURLResponse *urlResponse, NSError *error) {
NSDictionary *dict =
(NSDictionary *)[NSJSONSerialization
JSONObjectWithData:responseData1 options:0 error:nil];
// Log the result
NSLog(@"%@", dict);
NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]];
NSLog(@"status : %@", output);
dispatch_async(dispatch_get_main_queue(), ^{
// perform an action that updates the UI...
UIAlertView *customAlertView = [[UIAlertView alloc]initWithTitle:@"Social Media"
message:@"successful share"
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"OK",nil];
[customAlertView show];
[customAlertView release];
});
}];
}
else
{
// Alert Please login through seeting
dispatch_async(dispatch_get_main_queue(), ^{
// perform an action that updates the UI...
UIAlertView *customAlertView = [[UIAlertView alloc]initWithTitle:@"Social Media"
message:@"Please enable twitter through iPhone Settings"
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"OK",nil];
[customAlertView show];
[customAlertView release];
});
}
}];
}
{
NSString*strTwitterMessage;
strTwitterMessage=[NSString stringWithFormat:@“测试twitter帖子:照片链接URL”];
ACAccountStore*accountStore=[[ACAccountStore alloc]init];
ACAccountType*accountType=[accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierWitter];
[accountStore requestAccessToAccountsWithType:accountType with CompletionHandler:^(已授予布尔,N错误*错误){
如果(授予){
//获取Twitter帐户列表。
NSArray*accountsArray=[accountStore accountsWithAccountType:accountType];
NSLog(@“计数:%d”,[accountsArray计数]);
账户*推特账户;
int flagTwitter;
flagTwitter=0;
对于(int i=0;i@H2CO3..Had编辑问题。希望你知道我尝试了什么。如果你对tweetcomposeviewcontroller有任何了解,请帮助我。