pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <small id='UrcUo'></small><noframes id='UrcUo'>

    <tfoot id='UrcUo'></tfoot>
    <legend id='UrcUo'><style id='UrcUo'><dir id='UrcUo'><q id='UrcUo'></q></dir></style></legend>
      • <bdo id='UrcUo'></bdo><ul id='UrcUo'></ul>

    1. <i id='UrcUo'><tr id='UrcUo'><dt id='UrcUo'><q id='UrcUo'><span id='UrcUo'><b id='UrcUo'><form id='UrcUo'><ins id='UrcUo'></ins><ul id='UrcUo'></ul><sub id='UrcUo'></sub></form><legend id='UrcUo'></legend><bdo id='UrcUo'><pre id='UrcUo'><center id='UrcUo'></center></pre></bdo></b><th id='UrcUo'></th></span></q></dt></tr></i><div class="gaiukao" id='UrcUo'><tfoot id='UrcUo'></tfoot><dl id='UrcUo'><fieldset id='UrcUo'></fieldset></dl></div>

      如何使用 Twitter API 1.1 獲取用戶圖像?

      How to get user image with Twitter API 1.1?(如何使用 Twitter API 1.1 獲取用戶圖像?)
        <tbody id='jgfbL'></tbody>

    2. <tfoot id='jgfbL'></tfoot>

      <small id='jgfbL'></small><noframes id='jgfbL'>

    3. <legend id='jgfbL'><style id='jgfbL'><dir id='jgfbL'><q id='jgfbL'></q></dir></style></legend>
        <bdo id='jgfbL'></bdo><ul id='jgfbL'></ul>
        <i id='jgfbL'><tr id='jgfbL'><dt id='jgfbL'><q id='jgfbL'><span id='jgfbL'><b id='jgfbL'><form id='jgfbL'><ins id='jgfbL'></ins><ul id='jgfbL'></ul><sub id='jgfbL'></sub></form><legend id='jgfbL'></legend><bdo id='jgfbL'><pre id='jgfbL'><center id='jgfbL'></center></pre></bdo></b><th id='jgfbL'></th></span></q></dt></tr></i><div class="maks0cu" id='jgfbL'><tfoot id='jgfbL'></tfoot><dl id='jgfbL'><fieldset id='jgfbL'></fieldset></dl></div>

                本文介紹了如何使用 Twitter API 1.1 獲取用戶圖像?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                在 API 1.0 中,我們可以使用 users/profile_image/:screen_name

                例如:http://api.twitter.com/1/users/profile_image/EA_FIFA_FRANCE

                但是,它在 API 1.1 中不再起作用.

                請問您有解決方案嗎?

                解決方案

                用戶頭像

                好的,所以您需要用戶的個人資料圖片.您將需要查看 旨在幫助大家輕松或毫不費力地向 1.1 API 發出經過身份驗證的請求.

                當您使用它時,您會得到上面看到的響應.按照帖子說明,一步一步,您可以在此處獲取庫(您只需在項目中包含一個文件).

                基本上,上一篇文章解釋了您需要執行以下操作:

                • 創建一個 Twitter 開發者帳戶
                • 從 Twitter 獲取一組獨特的密鑰(總共 4 個密鑰).
                • 將您的應用設置為具有讀/寫訪問權限
                • 包括 TwitterApiExchange.php(庫)
                • 將您的密鑰放入 $settings 數組
                • 從文檔中選擇您的 URL 和請求方法(發布/獲取)(我把鏈接放在上面!)
                • 提出請求,就是這樣!

                一個實際例子

                我假設您按照上述帖子中的分步說明進行操作(包含漂亮的彩色圖片).這是您用來獲得所需內容的代碼.

                //需要庫文件,很明顯require_once('TwitterAPIExchange.php');//使用您從開發站點獲得的密鑰設置您的設置$設置=數組('oauth_access_token' =>"YOUR_ACCESS_TOKEN",'oauth_access_token_secret' =>"YOUR_ACCESS_TOKEN_SECRET",'consumer_key' =>"YOUR_CONSUMER_KEY",'consumer_secret' =>YOUR_CONSUMER_SECRET");//從文檔中選擇你想要的 url,這是 users/show$url = 'https://api.twitter.com/1.1/users/show.json';//根據文檔,請求方法是 GET,而不是 POST$requestMethod = 'GET';//設置你的獲取字符串,我們在這里使用我的網名$getfield = '?screen_name=j7mbo';//創建對象$twitter = new TwitterAPIExchange($settings);//發出請求并將響應放入 $json 變量中$json = $twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest();//是json,所以解碼成數組$result = json_decode($json);//訪問數組中的 profile_image_url 元素回聲 $result->profile_image_url;

                差不多就是這樣!很簡單的.還有 users/lookup 可以有效地做同樣的事情,但你可以:

                <塊引用>

                根據傳遞給 user_id 和/或 screen_name 參數的逗號分隔值的指定,為每個請求返回最多 100 個用戶的完全水合用戶對象.

                如果您需要獲取多個用戶的詳細信息,請使用它,但由于您只需要一個用戶的詳細信息,請使用如上所示的 users/show.

                我希望能把事情弄清楚一點!

                In API 1.0, we can use users/profile_image/:screen_name

                For example : http://api.twitter.com/1/users/profile_image/EA_FIFA_FRANCE

                But, it doesn't work anymore in API 1.1.

                Do you have a solution, please ?

                解決方案

                The user's profile image

                Okay, so you want a user's profile image. You're going to need to take a look at the twitter REST API 1.1 docs. This is a list of all the different requests you can make to their API (don't worry, I'll get to how you actually do this later on).

                There are multiple ways to get the user's profile image, but the most notable one is: users/show. According to the docs for this, the users/show method:

                Returns a variety of information about the user specified by the required user_id or screen_name parameter. The author's most recent Tweet will be returned inline when possible.

                Well, the user profile image must be in there somewhere, correct?

                Let's have a look at a typical response to a request for this information, using the users/show url (we'll use my profile as an example).

                I've cut off some from the bottom, because there is a lot of data to go through. Most importantly, you'll see what you require:

                This is the profile_image_url key that you need to get access to.

                So, how do you do all this? It's pretty simple, actually.

                Authenticated Requests

                As you rightly pointed out, as of June 11th 2013 you can't make unauthenticated requests, or any to the 1.0 API any more, because it has been retired. So OAuth is the way to make requests to the 1.1 API.

                I wrote a stack overflow post with an aim to help all you guys make authenticated requests to the 1.1 API with little to no effort.

                When you use it, you'll get back the response you see above. Follow the posts instructions, step-by-step, and you can get the library here (you only need to include one file in your project).

                Basically, the previous post explains that you need to do the following:

                • Create a twitter developer account
                • Get yourself a set of unique keys from twitter (4 keys in total).
                • Set your application to have read/write access
                • Include TwitterApiExchange.php (the library)
                • Put your keys in a $settings array
                • Choose your URL and request method (Post/Get) from the docs (I put the link above!)
                • Make the request, that's it!

                A practical example

                I'm going to assume you followed the step-by-step instructions in the above post (containing pretty colour pictures). Here's the code you would use to get what you want.

                // Require the library file, obviously
                require_once('TwitterAPIExchange.php');
                
                // Set up your settings with the keys you get from the dev site
                $settings = array(
                    'oauth_access_token' => "YOUR_ACCESS_TOKEN",
                    'oauth_access_token_secret' => "YOUR_ACCESS_TOKEN_SECRET",
                    'consumer_key' => "YOUR_CONSUMER_KEY",
                    'consumer_secret' => "YOUR_CONSUMER_SECRET"
                );
                
                // Chooose the url you want from the docs, this is the users/show
                $url = 'https://api.twitter.com/1.1/users/show.json';
                // The request method, according to the docs, is GET, not POST
                $requestMethod = 'GET';
                
                // Set up your get string, we're using my screen name here
                $getfield = '?screen_name=j7mbo';
                
                // Create the object
                $twitter = new TwitterAPIExchange($settings);
                
                // Make the request and get the response into the $json variable
                $json =  $twitter->setGetfield($getfield)
                                 ->buildOauth($url, $requestMethod)
                                 ->performRequest();
                
                // It's json, so decode it into an array
                $result = json_decode($json);
                
                // Access the profile_image_url element in the array
                echo $result->profile_image_url;
                

                That's pretty much it! Very simple. There's also users/lookup which effectively does the same thing, but you can:

                Returns fully-hydrated user objects for up to 100 users per request, as specified by comma-separated values passed to the user_id and/or screen_name parameters.

                If you ever need to get more than one user's details, use that, but as you only require one user's details, use users/show as above.

                I hope that cleared things up a bit!

                這篇關于如何使用 Twitter API 1.1 獲取用戶圖像?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                PHP PDO ODBC connection(PHP PDO ODBC 連接)
                Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                  <tbody id='7l67K'></tbody>

                <legend id='7l67K'><style id='7l67K'><dir id='7l67K'><q id='7l67K'></q></dir></style></legend>

                <small id='7l67K'></small><noframes id='7l67K'>

                    • <i id='7l67K'><tr id='7l67K'><dt id='7l67K'><q id='7l67K'><span id='7l67K'><b id='7l67K'><form id='7l67K'><ins id='7l67K'></ins><ul id='7l67K'></ul><sub id='7l67K'></sub></form><legend id='7l67K'></legend><bdo id='7l67K'><pre id='7l67K'><center id='7l67K'></center></pre></bdo></b><th id='7l67K'></th></span></q></dt></tr></i><div class="scsw2co" id='7l67K'><tfoot id='7l67K'></tfoot><dl id='7l67K'><fieldset id='7l67K'></fieldset></dl></div>
                      <tfoot id='7l67K'></tfoot>

                      • <bdo id='7l67K'></bdo><ul id='7l67K'></ul>
                        1. 主站蜘蛛池模板: 粘度计维修,在线粘度计,二手博勒飞粘度计维修|收购-天津市祥睿科技有限公司 | 圆周直径尺-小孔内视镜-纤维研磨刷-东莞市高腾达精密工具 | sus630/303cu不锈钢棒,440C/430F/17-4ph不锈钢研磨棒-江苏德镍金属科技有限公司 | 家德利门业,家居安全门,别墅大门 - 安徽家德利门业有限公司 | 引领中高档酒店加盟_含舍·美素酒店品牌官网 | 冷却塔减速机器_冷却塔皮带箱维修厂家_凉水塔风机电机更换-广东康明冷却塔厂家 | 蔬菜清洗机_环速洗菜机_异物去除清洗机_蔬菜清洗机_商用洗菜机 - 环速科技有限公司 | 油液红外光谱仪-油液监测系统-燃油嗅探仪-上海冉超光电科技有限公司 | 锂电池砂磨机|石墨烯砂磨机|碳纳米管砂磨机-常州市奥能达机械设备有限公司 | 工业淬火油烟净化器,北京油烟净化器厂家,热处理油烟净化器-北京众鑫百科 | 组织研磨机-高通量组织研磨仪-实验室多样品组织研磨机-东方天净 传递窗_超净|洁净工作台_高效过滤器-传递窗厂家广州梓净公司 | UV固化机_UVLED光固化机_UV干燥机生产厂家-上海冠顶公司专业生产UV固化机设备 | PVC地板|PVC塑胶地板|PVC地板厂家|地板胶|防静电地板-无锡腾方装饰材料有限公司-咨询热线:4008-798-128 | 无压烧结银_有压烧结银_导电银胶_导电油墨_导电胶-善仁(浙江)新材料 | 贵阳用友软件,贵州财务软件,贵阳ERP软件_贵州优智信息技术有限公司 | 变色龙云 - 打包app_原生app_在线制作平台_短链接_ip查询 | 济南网站建设|济南建网站|济南网站建设公司【济南腾飞网络】【荐】 | 复合肥,化肥厂,复合肥批发,化肥代理,复合肥品牌-红四方 | 双舌接地线-PC68数字式高阻计-ZC36|苏海百科 | 济南网站策划设计_自适应网站制作_H5企业网站搭建_济南外贸网站制作公司_锐尚 | 深圳成考网-深圳成人高考报名网 深圳工程师职称评定条件及流程_深圳职称评审_职称评审-职称网 | 英国公司注册-新加坡公司注册-香港公司开户-离岸公司账户-杭州商标注册-杭州优创企业 | 高低温万能试验机-复合材料万能试验机-馥勒仪器 | 铜镍-康铜-锰铜-电阻合金-NC003 - 杭州兴宇合金有限公司 | 电线电缆厂家|沈阳电缆厂|电线厂|沈阳英联塑力线缆有限公司 | 通风气楼_通风天窗_屋顶风机-山东美创通风设备有限公司 | 快速门厂家批发_PVC快速卷帘门_高速门_高速卷帘门-广州万盛门业 快干水泥|桥梁伸缩缝止水胶|伸缩缝装置生产厂家-广东广航交通科技有限公司 | 预制围墙_工程预制围墙_天津市瑞通建筑材料有限公司 | ERP企业管理系统永久免费版_在线ERP系统_OA办公_云版软件官网 | 冷柜风机-冰柜电机-罩极电机-外转子风机-EC直流电机厂家-杭州金久电器有限公司 | 商用绞肉机-熟肉切片机-冻肉切丁机-猪肉开条机 - 广州市正盈机械设备有限公司 | 新材料分散-高速均质搅拌机-超声波分散混合-上海化烁智能设备有限公司 | 全自动在线分板机_铣刀式在线分板机_曲线分板机_PCB分板机-东莞市亿协自动化设备有限公司 | 对辊破碎机-液压双辊式,强力双齿辊,四辊破碎机价格_巩义市金联机械设备生产厂家 | 噪声治理公司-噪音治理专业隔音降噪公司 | 小小作文网_中小学优秀作文范文大全| 小型手持气象站-空气负氧离子监测站-多要素微气象传感器-山东天合环境科技有限公司 | 天津蒸汽/热水锅炉-电锅炉安装维修直销厂家-天津鑫淼暖通设备有限公司 | 卡诺亚轻高定官网_卧室系统_整家定制_定制家居_高端定制_全屋定制加盟_定制家具加盟_定制衣柜加盟 | 螺纹三通快插接头-弯通快插接头-宁波舜驰气动科技有限公司 | 防水套管|柔性防水套管|伸缩器|伸缩接头|传力接头-河南伟创管道 防水套管_柔性防水套管_刚性防水套管-巩义市润达管道设备制造有限公司 |