tumblr iPhone 集成
您好,我已经在不倒翁中完成了状态更新,但是当我以数据形式发送照片时遇到问题,如下所示。
-(IBAction)sendPhoto
{
NSString *email = @"[email protected]";
NSString *password = @"password";
NSString *sendType = @"photo";
UIImage *imageMS = [UIImage imageNamed:@"Submit.png"];
NSData *photoData = [[NSData alloc] initWithData:UIImagePNGRepresentation(imageMS)];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]
initWithURL:[NSURL URLWithString:@"http://www.tumblr.com/api/write"]];
[request setHTTPMethod:@"POST"];
NSString *request_body = [NSString
stringWithFormat:@"email=%@&password=%@&type=%@&data=%@",
[email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
[password stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
[sendType stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
photoData];
[request setHTTPBody:[request_body dataUsingEncoding:NSUTF8StringEncoding]];
[web loadRequest:request];
}
但它没有得到更新。为什么?
Hi i have done with status update in tumbler but i am facing problem when i am sending photo in the form of data, as shown below.
-(IBAction)sendPhoto
{
NSString *email = @"[email protected]";
NSString *password = @"password";
NSString *sendType = @"photo";
UIImage *imageMS = [UIImage imageNamed:@"Submit.png"];
NSData *photoData = [[NSData alloc] initWithData:UIImagePNGRepresentation(imageMS)];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]
initWithURL:[NSURL URLWithString:@"http://www.tumblr.com/api/write"]];
[request setHTTPMethod:@"POST"];
NSString *request_body = [NSString
stringWithFormat:@"email=%@&password=%@&type=%@&data=%@",
[email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
[password stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
[sendType stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
photoData];
[request setHTTPBody:[request_body dataUsingEncoding:NSUTF8StringEncoding]];
[web loadRequest:request];
}
But it is not getting updated. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我原来的答案被证明是不正确的,但OP发布了一个代码链接,他说解决了他的问题。我复制了下面的代码,以便将来的搜索者可以轻松找到它,因为我知道看到描述的问题并找到解决方案的链接却发现该链接已失效是多么令人沮丧。
代码基于 http://forums.macrumors.com/showthread.php?t=427513< /a>:
我修改了上面的代码以消除一些内存问题并添加一些参数以使其成为更通用/灵活的解决方案。但是,如果有人想要该网站上发布的原始代码,只需查看此答案的编辑修订版本即可。
My original answer proved to be incorrect, but the OP posted a link to code that he said fixed his problem. I have copied that code below so that future searchers can find it easily, since I know how frustrating it can be to see your problem described and find a link to the solution only to have that link be dead.
Code based on http://forums.macrumors.com/showthread.php?t=427513:
I have modified the above code to eliminate some memory issues and to add some parameters to make this a more generic/flexible solution. However, if someone would like the original code as posted on that site, just look through this answer's edit revisions.
为了将来参考,ASIHTTPRequest 的 ASIFormDatRequest 使这种事情变得更加容易。
For future reference, ASIHTTPRequest's ASIFormDatRequest makes this sort of thing much easier.