日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

技术分享-QQ接口

發布時間:2023/12/29 编程问答 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 技术分享-QQ接口 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

作者:劉旭濠

接口是什么,大家應該在手機APP就遇到過吧比如一個APP登錄下面會顯示多種登錄方式,有微信,QQ等接口,那么接口的大概意思就是,如果你想在一個APP用QQ登錄就要通過接口的形式來進行訪問
步驟呢就是這幾個:消息提示(就是提示你登錄是否成功),數據訪問(訪問你的QQ數據大概吧,我也不是很清楚),解析數據(分析你的數據),存儲本地(保存登錄數據在本地),事件綁定(綁定按鈕事件),跳轉頁面(登錄成功跳轉到主頁)。

比如上圖魚圈的登錄界面是有3個登錄的接口,一個是QQ,一個是微信,一個是新浪,要是登錄成功就跳轉到主頁面就是聊天界面,

那么接口是該如何獲取呢
接下來跟大家講一下第三方的QQ接口。
首先要去QQ互聯登錄申請一個,那么為什么要申請呢,因為他會給你分配一個appid和一個appkey給,不然不管你怎么弄都是沒有資格去第三方登錄的,申請時間大概要一個星期左右這么多吧(好久)
然后如果獲取到了appid和appkey然后我們開始就需要開發后臺了我們先去獲取一個java sdk是java sdk不是js sdk(我一開始也是看錯了兩個都差不多一樣難怪沒反應)http://wiki.open.qq.com/wiki/website/SDK下載 這個SDK的下載地址。

然后就將jar包放進自己的項目里面,然后接著下一步打開qqconnectconfig.properties

app_ID = 100****(請修改此處) app_KEY = ******(請修改此處) redirect_URI = ***********(請修改此處) scope = get_user_info,add_topic,add_one_blog,add_album,upload_pic,list_album,add_share,check_page_fans,add_t,add_pic_t,del_t,get_repost_list,get_info,get_other_info,get_fanslist,get_idollist,add_idol,del_ido,get_tenpay_addr(請修改此處) baseURL = https://graph.qq.com/ getUserInfoURL = https://graph.qq.com/user/get_user_info accessTokenURL = https://graph.qq.com/oauth2.0/token authorizeURL = https://graph.qq.com/oauth2.0/authorize getOpenIDURL = https://graph.qq.com/oauth2.0/me addTopicURL = https://graph.qq.com/shuoshuo/add_topic addBlogURL = https://graph.qq.com/blog/add_one_blog addAlbumURL = https://graph.qq.com/photo/add_album uploadPicURL = https://graph.qq.com/photo/upload_pic listAlbumURL = https://graph.qq.com/photo/list_album addShareURL = https://graph.qq.com/share/add_share checkPageFansURL = https://graph.qq.com/user/check_page_fans addTURL = https://graph.qq.com/t/add_t addPicTURL = https://graph.qq.com/t/add_pic_t delTURL = https://graph.qq.com/t/del_t getWeiboUserInfoURL = https://graph.qq.com/user/get_info getWeiboOtherUserInfoURL = https://graph.qq.com/user/get_other_info getFansListURL = https://graph.qq.com/relation/get_fanslist getIdolsListURL = https://graph.qq.com/relation/get_idollist addIdolURL = https://graph.qq.com/relation/add_idol delIdolURL = https://graph.qq.com/relation/del_idol getTenpayAddrURL = https://graph.qq.com/cft_info/get_tenpay_addr getRepostListURL = https://graph.qq.com/t/get_repost_list version = 2.0.0.0 上面需要修改的四處要根據自己的信息來進行修改 app_ID申請下來的 appid app_KEY申請下來的 appkey redirect_URI自己申請時候填寫的回調地址 redirect_URI

下圖是用戶類型API接口

我們一般的話第一個就可以 會獲取到qq的名稱性別和頭像,如果需要其他的話也可以自己去申請 。你自己有什么權限的你就可以早scope后面添加
到這里我們的準備工作就準備好了,然后開始直接測試,先測試一下自己的接口能不能用
開始QQ的接口了

<a href = "<%=path%>/qq/QQlogin" > 請使用你的QQ賬號登陸 </ a > < a href="<%=path%>/qq/afterlogin">回調的測試</a>@RequestMapping("/qq/QQlogin")//QQ登錄protected void doGet(HttpServletRequest request, HttpServletResponse response, Model model) throws IOException {response.setContentType("text/html;charset=utf-8");try {/* String authorizeURL = new Oauth().getAuthorizeURL(request);*/response.sendRedirect(new Oauth().getAuthorizeURL(request));} catch (QQConnectException e) {e.printStackTrace();} }回調測試 @RequestMapping("/qq/afterlogin")public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {try {AccessToken accessTokenObj = (new Oauth()).getAccessTokenByRequest(request);String accessToken = null,openID = null;long tokenExpireIn = 0L;if (accessTokenObj.getAccessToken().equals("")){System.out.print("沒有獲取到響應參數");}else{accessToken = accessTokenObj.getAccessToken();tokenExpireIn = accessTokenObj.getExpireIn();OpenID openIDObj = new OpenID(accessToken);openID = openIDObj.getUserOpenID();UserInfo qzoneUserInfo = new UserInfo(accessToken, openID);UserInfoBean userInfoBean = qzoneUserInfo.getUserInfo();}}catch(Exception e){e.printStackTrace();}return null; }

以上接口就完成,這是QQ的接口,微信和新浪的接口應該大致都一樣,后面我可能會繼續分享微信,新浪的接口

總結

以上是生活随笔為你收集整理的技术分享-QQ接口的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。