腾讯开放平台记录笔记

腾讯互联开放平台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 @   cntnn11  阅读(497)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述
点击右上角即可分享
微信分享提示