【发布时间】:2013-12-16 08:39:07
【问题描述】:
我的问题是我可以成功登录 tumblr 但是无法在 tumblr 上发帖。 下面是我的代码
NSString *path = @"blog/myName.tumblr.com//post"; // set your Tumblr name here
NSDictionary *parameters = @{@"type" : @"text",
@"title" : @"I'm On on Tumblr",
@"body" : @"Its going to be fun"};
NSURLRequest *preparedRequest = [OAuth1Controller preparedRequestForPath:path
parameters:parameters
HTTPmethod:@"POST"
oauthToken:_oauthToken
oauthSecret:_oauthTokenSecret];
// Send the request and when received show the response in the text view
[NSURLConnection sendAsynchronousRequest:preparedRequest
queue:NSOperationQueue.mainQueue
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
self.promptView.text = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
if (error) NSLog(@"Error in API request: %@", error.localizedDescription);
});
}];
下面是我设置 ConsumerKey、ConsumerSecrete 和回调 URL 的 oAuthController 实现文件
#define OAUTH_CALLBACK @"tumblr_callback" //Sometimes this has to be the same as the registered app callback url
#define CONSUMER_KEY @"MyKey"
#define CONSUMER_SECRET @"MySecretKey"
#define AUTH_URL @"http://www.tumblr.com/oauth/"
#define REQUEST_TOKEN_URL @"request_token"
#define AUTHENTICATE_URL @"authorize"
#define ACCESS_TOKEN_URL @"access_token"
#define API_URL @"http://api.tumblr.com/v2/"
#define OAUTH_SCOPE_PARAM @""
下面是我收到的错误的屏幕截图
我哪里做错了。请对此提供任何帮助。
提前致谢。
【问题讨论】:
标签: ios objective-c oauth tumblr