腾讯开放平台记录笔记

腾讯互联开放平台OAUTH2

      API文档URL:http://wiki.opensns.qq.com/wiki/【QQ登录】API文档

      错误代码返回URL:http://wiki.opensns.qq.com/wiki/【QQ登录】公共返回码说明

     

      公用参数:

            oauth_consumer_key 应用的appid

            //用户授权码和openid是用户在绑定qq时获取的!如果没有绑定就无法使用任何API接口

            access_token 用户的授权代码

            openid 用户的ID

            示例:https://graph.qq.com/user/get_user_info?access_token=用户授权的code&openid=用户的授权uid&oauth_consumer_key=应用appid

 

      其他接口API

            //发一篇文章到qq空间里

            接口:https://graph.qq.com/blog/add_one_blog [需要授权]

            参数:

                  title 标题

                  content 文章内容

                  format API返回的数据格式 xml/json

            提交方式:POST

            完整示例:https://graph.qq.com/blog/add_one_blog?access_token=用户授权的code&openid=用户的授权uid&oauth_consumer_key=应用appid&format=json&title=url_encode(标题)&content=url_encode(内容)

           

            接口:https://graph.qq.com/share/add_share [需要授权]

            参数:

                  title '分享标题';

                  url '分享的URL地址';

                  comment '这是分享理由';

                  summary '分享网页内容摘要';

                  images 'http://imgcache.qq.com/QzonePortal_v2/city_v2/img/news_img/2011/0526/portal_new_1306376959_375.jpg';//图片地址

            完整示例:https://graph.qq.com/share/add_share?access_token=用户授权token&openid=用户唯一标识&oauth_consumer_key=应用申请时的ID&title=QQ空间&url=http://2012.douguo.com/diet/detail/380619&comment=这是分享理由&summary=分享网页内容摘要&images=http://imgcache.qq.com/QzonePortal_v2/city_v2/img/news_img/2011/0526/portal_new_1306376959_375.jpg"

================================================================================================

腾讯微博开放平台

      腾讯微博API文档查询页面:http://wiki.open.t.qq.com/index.php/API文档

      授权及接口调试工具页面:http://dev.t.qq.com/auth_tool/main.html#13

      发布一个带图片以及链接的微博

            提交参数:

                  oauth_consumer_key = 应用appid

                  access_token            = 用户授权code 可变的

                  oauth_version          = '2.a';[固定值]

                  openid                    = 用户uid[用户授权返回的uid]

                  format                    = 'json/xml';

                  content                   = '微博的内容';140个汉字

                  jing                   = '经度';

                  wei                         = '纬度';

                  pic_url                    = 图片路径;

            提交方式:[CURL 模拟POST请求提交]

                  $url = "https://open.t.qq.com/api/t/add_pic_url";//发布带图片的微博

                  $url = "https://open.t.qq.com/api/t/add";    //发布一篇微博

                  $ci = curl_init();

                  curl_setopt($ci, CURLOPT_USERAGENT, 'PHP-SDK OAuth2.0');

                  curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 3);

                  curl_setopt($ci, CURLOPT_TIMEOUT, 3);

                  curl_setopt($ci, CURLOPT_RETURNTRANSFER, true);

                  curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, false);

                  curl_setopt($ci, CURLOPT_SSL_VERIFYHOST, false);

                  curl_setopt($ci, CURLOPT_HEADER, false);

                  curl_setopt($ci, CURLOPT_POST, TRUE);

                  curl_setopt($ci, CURLOPT_POSTFIELDS, http_build_query($data));

                  curl_setopt($ci, CURLINFO_HEADER_OUT, TRUE );

                  curl_setopt($ci, CURLOPT_URL, $url);

                  $r = curl_exec($ci);//执行。接收返回结果

                  curl_close($ci);   //关闭curl资源

                  $r   = preg_replace('/[^\x20-\xff]*/', "", $r); //清除不可见字符

                  $r   = iconv("utf-8", "utf-8//ignore", $r); //UTF-8转码

     

      

posted @ 2013-03-07 14:08  cntnn11  阅读(488)  评论(0编辑  收藏  举报