我想知道,有什么方法可以在twitter中用一些文字发布图片,有人建议使用“http://tinyurl.com/”。我不知道从哪里开始,在我的以前的应用程序中,我成功地抽动了,但只包含文本。 正确的方向继续将是一个很大的帮助。如何用iPhone中的某些文字抽出图片
0
A
回答
1
有几种方法。我建议你使用ShareKit。它为你做了大部分工作。
0
要将图像发布到Twitter,我们必须先将图像发布到twit中,然后我们必须将该网址发送到twitter,这是将图像发送到twitter的过程,这是将图像发送到twitter的示例代码。 ........
NSString *postUrl = @"https://api.twitter.com/1/statuses/update.json";
ASIFormDataRequest *request = [[ASIFormDataRequest alloc]
initWithURL:[NSURL URLWithString:postUrl]];
NSMutableDictionary *postInfo = [NSMutableDictionary
dictionaryWithObject:statusText.text
forKey:@"status"];
NSLog(@"%@",postInfo);
NSString *str1= statusText.text;
NSLog(@"Status posted. HTTP result code: %d", request.responseStatusCode);
[request release];
[statusText resignFirstResponder];
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:[oAuth oAuthHeaderForMethod:@"GET"
andUrl:@"https://api.twitter.com/1/account/verify_credentials.json"
andParams:nil]];
[req setData:UIImageJPEGRepresentation(imageView.image, 0.8) forKey:@"media"];
// Define this somewhere or replace with your own key inline right here.
[req setPostValue:@"74734e805f2ad85afae441ca12c16087" forKey:@"key"];
[req startSynchronous];
NSLog(@"Got HTTP status code from TwitPic: %d", [req responseStatusCode]);
NSLog(@"Response string: %@", [req responseString]);
NSDictionary *twitpicResponse = [[req responseString] JSONValue];
NSLog(@"%@",[[req responseString] JSONValue]);
textView.text = [NSString stringWithFormat:@"Posted image URL: %@", [twitpicResponse valueForKey:@"url"]];
NSString *str=[NSString stringWithFormat:@" %@",[twitpicResponse valueForKey:@"url"]];
NSLog(@"%@",str);
if([str isEqualToString:@" (null)"])
{
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Message" message:@"Could not authenticate you(header rejected by twitter)" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alertView show];
}
else
{
NSString *postUrl = @"https://api.twitter.com/1/statuses/update.json";
ASIFormDataRequest *request = [[ASIFormDataRequest alloc]
initWithURL:[NSURL URLWithString:postUrl]];
NSString *txtmessage=[str1 stringByAppendingString:str];
/*NSMutableDictionary *postInfo = [NSMutableDictionary
dictionaryWithObject:[twitpicResponse valueForKey:@"url"]
forKey:@"status"];*/
NSMutableDictionary *postInfo = [NSMutableDictionary
dictionaryWithObject:txtmessage
forKey:@"status"];
for (NSString *key in [postInfo allKeys]) {
[request setPostValue:[postInfo objectForKey:key] forKey:key];
}
[request addRequestHeader:@"Authorization"
value:[oAuth oAuthHeaderForMethod:@"POST"
andUrl:postUrl
andParams:postInfo]];
[request startSynchronous];
if(request.responseStatusCode!=200)
{
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Message" message:@"Already posted" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alertView show];
}
else {
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Message" message:@"sucess" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alertView show];
}
NSLog(@"Status posted. HTTP result code: %d", request.responseStatusCode);
statusText.text = @"";
[request release];
[statusText resignFirstResponder];
}
相关问题
- 1. 如何将SWT的某些控件导出为SVG图片?
- 2. iphone uipickerview:图片和文字
- 3. 如何用extJS中的某些内容替换某些文本?
- 4. 如何使某些字段出现在R文件中?
- 5. 如何在iPhone中从NSString中删除某些字符?
- 6. 如何在excel中使用大文本中的某些字符
- 7. 从Facebook中抽出最新图片
- 8. 某些网站图片在iPhone上无法正常显示
- 9. 某些图片不能在iphone上显示
- 10. 导出的图表在某些文件夹中不起作用?
- 11. Cardview使用图片从url中抽出片段
- 12. 我如何在某些文本的同一行中获取图片(标记)?
- 13. 如何使用CSS替换某些文字中的单词?
- 14. 如何用python交换文件中的某些字节?
- 15. 如何在Android中为某些图片部件着色?
- 16. 如何在iOS中拖动某些图片?
- 17. 如何在某些文字的右侧显示评分图标
- 18. 图片上传PHP只适用于某些图片(已解决)
- 19. 某些URL下载的图片与Python
- 20. 如何禁用某些图像的colorbox
- 21. 如何锁定某些视图控制器的iPhone方向 - Swift?
- 22. 用于居中某些文字的图像任务
- 23. 如何在objective-c iPhone上的图片上写文字?
- 24. 在某个文件夹中显示图片,iPhone
- 25. 如何列出Web服务器上某些文件夹中的某些特定图像?
- 26. 如何使用ggplot在图上写出某些参数的值
- 27. 如何在某些div中插入每个图库的图片? WordPress的
- 28. 如何直接从某些网站的网址下载图片?
- 29. 如何删除某些州的UIButton图片?
- 30. 如何插入PNG图片中的iPhone
其实我发现,我想要的是无法实现的,微博,不以任何TWIT显示图像,而它通过点击显示在不同的窗口中的图像解决方案链接的图像....我们使用tinyurl,因为url的长度实际上可以非常大,twitter只支持140个字符。虽然你的链接为我提供了一个很好的API用于进一步使用...感谢那:) – 2011-02-28 09:52:38