新浪微博获得已授权的key后怎么调用API

iOS 码拜 9年前 (2015-05-08) 864次浏览 0个评论
 

新浪的API文档发表一条微博的示例:

XML
curl -u “username:password” -d “”status=abc&annotations=[{“type2″:123}]”” “http://api.t.sina.com.cn/statuses/update.xml?source=appkey” 
JSON
curl -u “username:password” -d “”status=abc&annotations=[{“type2″:123}]”” “http://api.t.sina.com.cn/statuses/update.json?source=appkey” 

但不知道怎么用  这是什么意思啊,已取得的oauth_token 怎么用进去啊

有好心人帮帮忙吗 

8分
curl是一款linux下的应用程序,支持http协议,如果你没有linux,在windows 下安装cygwin也是有curl这个程序的。
其实主要想知道怎么调用API的。

新浪微博,如果取得了一些参数,看下我这么组的对吗,一些参数已经获取到了
    //prepar request
    NSString *urlString = [NSString stringWithFormat:@”  http://api.t.sina.com.cn/statuses/update.json?”];
    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
    [request setURL:[NSURL URLWithString:urlString]];
    [request setHTTPMethod:@”POST”];
    
    //create the body
    NSString *xmlContents = [[NSString alloc] initWithFormat:@”oauth_consumer_key=%@&oauthToken=%@&oauth_signature_method=%@&oauth_signature=%@&oauth_timestamp=%@&oauth_nonce=%@&oauth_version=1.0&status=发微博内容”, oauth_consumer_key,oauthToken,oauth_signature_method,oauth_signature,oauth_timestamp,oauth_nonce];
    
    
    NSMutableData *postBody = [NSMutableData data];
    [postBody appendData:[xmlContents dataUsingEncoding:NSUTF8StringEncoding]];
    
    
    //post上微博发表请求
    [request setHTTPBody:postBody];

12分
新浪微博有现成的objc sdk可用,最好不要自己搞

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明新浪微博获得已授权的key后怎么调用API
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!