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

    • <bdo id='lpF1d'></bdo><ul id='lpF1d'></ul>
  1. <small id='lpF1d'></small><noframes id='lpF1d'>

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

    1. <legend id='lpF1d'><style id='lpF1d'><dir id='lpF1d'><q id='lpF1d'></q></dir></style></legend>
    2. iPhone- Twitter API 獲取用戶關注者/關注者

      iPhone- Twitter API GET Users Followers/Following(iPhone- Twitter API 獲取用戶關注者/關注者)
        <bdo id='OWG0a'></bdo><ul id='OWG0a'></ul>

        <legend id='OWG0a'><style id='OWG0a'><dir id='OWG0a'><q id='OWG0a'></q></dir></style></legend>

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

          <tfoot id='OWG0a'></tfoot>
          <i id='OWG0a'><tr id='OWG0a'><dt id='OWG0a'><q id='OWG0a'><span id='OWG0a'><b id='OWG0a'><form id='OWG0a'><ins id='OWG0a'></ins><ul id='OWG0a'></ul><sub id='OWG0a'></sub></form><legend id='OWG0a'></legend><bdo id='OWG0a'><pre id='OWG0a'><center id='OWG0a'></center></pre></bdo></b><th id='OWG0a'></th></span></q></dt></tr></i><div class="0wc20cs" id='OWG0a'><tfoot id='OWG0a'></tfoot><dl id='OWG0a'><fieldset id='OWG0a'></fieldset></dl></div>

                <tbody id='OWG0a'></tbody>
                本文介紹了iPhone- Twitter API 獲取用戶關注者/關注者的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我希望能夠使用 iOS 5 的 Twitter API 來獲取所有用戶關注者和關注用戶名到 NSDictionary...

                不過,我遇到了障礙.我不知道如何使用 Twitter API 來做到這一點......但我的主要問題是首先獲取用戶的用戶名.當我什至不知道用戶的用戶名時,如何發出 API 請求來查找該用戶的關注者?

                誰能給我一個關于讓你的 Twitter 用戶關注和關注的例子嗎?

                PS:我已經添加了推特框架,并且導入了

                解決方案

                它是 Apple 的 Twitter API 和 Twitter 自己的 API 的組合.一旦你閱讀了代碼,它就相當簡單了.我將提供示例代碼,說明如何獲取 Twitter 帳戶的朋友"(這是用戶關注的人的術語),這應該足以讓您繼續了解獲取關注者的方法帳戶.

                首先,添加 AccountsTwitter 框架.

                現在,讓我們在用戶的設備上顯示 Twitter 帳戶.

                #import <Accounts/Accounts.h>-(無效)getTwitterAccounts {ACAccountStore *accountStore = [[ACAccountStore alloc] init];//創建確保檢索 Twitter 帳戶的帳戶類型.ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];//讓我們請求訪問并獲取帳戶[accountStore 請求AccessToAccountsWithType:accountTypewithCompletionHandler:^(BOOL 已授予,NSError *error) {//檢查用戶是否授予我們訪問權限并且沒有錯誤(例如沒有在用戶設備上添加帳戶)如果(授予 && !錯誤){NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];if ([accountsArray count] > 1) {//用戶可能有一個或多個帳戶添加到他們的設備//您需要顯示提示或單獨的視圖,讓用戶選擇您需要獲取關注者和朋友的帳戶} 別的 {[self getTwitterFriendsForAccount:[accountsArray objectAtIndex:0]];}} 別的 {//處理錯誤(顯示用戶未授予您的應用訪問權限等信息的警報)}}];}

                現在我們可以使用 GET Friends/ids 命令:

                #import <Twitter/Twitter.h>-(void)getTwitterFriendsForAccount:(ACAccount*)account {//在這種情況下,我正在為帳戶創建一個字典//添加賬戶網名NSMutableDictionary *accountDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:account.username, @"screen_name", nil];//添加用戶 ID(在我的情況下我需要它,但執行請求不是必需的)[accountDictionary setObject:[[[account dictionaryWithValuesForKeys:[NSArray arrayWithObject:@"properties"]] objectForKey:@"properties"] objectForKey:@"user_id"] forKey:@"user_id"];//設置 URL,你可以看到它只是 Twitter 自己的 API url 方案.在這種情況下,我們希望以 JSON 格式接收它NSURL *followingURL = [NSURL URLWithString:@"http://api.twitter.com/1/friends/ids.json"];//傳入參數(基本上是'.ids.json?screen_name=[screen_name]')NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:account.username, @"screen_name", nil];//設置請求TWRequest *twitterRequest = [[TWRequest alloc] initWithURL:followingURL參數:參數requestMethod:TWRequestMethodGET];//這個很重要!為請求設置帳戶,以便我們可以執行經過身份驗證的請求.如果沒有這個,您將無法獲得私人帳戶的關注者,如果您執行的請求過多,Twitter 也可能會返回錯誤[twitterRequest setAccount:account];//執行 Twitter 好友請求[twitterRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {如果(錯誤){//處理任何錯誤 - 請記住,盡管您可能會收到包含錯誤的有效響應,因此您可能需要查看響應并確保字典中不存在 'error:' 鍵}NSError *jsonError = nil;//將響應轉換為字典NSDictionary *twitterFriends = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONWritingPrettyPrinted error:&jsonError];//獲取 Twitter 返回的 Id 并將它們添加到我們之前創建的字典中[accountDictionary setObject:[twitterFriends objectForKey:@"ids"] forKey:@"friends_ids"];NSLog(@"%@", accountDictionary);}];}

                當您想要一個帳戶的關注者時,幾乎相同...只需使用 URL http://api.twitter.com/1/followers/ids.format 并傳入通過 GET follower/ids

                希望這能給您一個良好的開端.

                更新:

                正如評論中指出的,您應該使用更新后的 API 調用:https://api.twitter.com/1.1/followers/list.json

                I want to be able to use the Twitter API for ios 5 to get all of the user followers and following user name into a NSDictionary...

                I've hit a road block though. I don't know how to use the Twitter API the do this... But my main problem is getting the user's username in the first place. How can I make an API request to find this users followers when I don't even know the users username?

                Can someone give me an example on getting your Twitter users followers and following?

                PS: I've already added the Twitter framework, and imported

                解決方案

                It's a combination of Apple's Twitter API and Twitter's own API. It's fairly straight forward once you read the code. I'm going to provide sample code for how to get the 'friends' for a Twitter account (this is the term for people that a user follows), which should be enough to get you going on a method to obtain the followers for an account.

                First, add the Accounts and Twitter frameworks.

                Now, let's get the Twitter account(s) present on a user's device.

                #import <Accounts/Accounts.h>
                
                -(void)getTwitterAccounts {
                    ACAccountStore *accountStore = [[ACAccountStore alloc] init];
                    // Create an account type that ensures Twitter accounts are retrieved.
                    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
                    // let's request access and fetch the accounts
                    [accountStore requestAccessToAccountsWithType:accountType
                                            withCompletionHandler:^(BOOL granted, NSError *error) {
                                                // check that the user granted us access and there were no errors (such as no accounts added on the users device)
                                                if (granted && !error) {
                                                    NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
                                                    if ([accountsArray count] > 1) {
                                                        // a user may have one or more accounts added to their device
                                                        // you need to either show a prompt or a separate view to have a user select the account(s) you need to get the followers and friends for 
                                                    } else {
                                                        [self getTwitterFriendsForAccount:[accountsArray objectAtIndex:0]];
                                                    }
                                                } else {
                                                    // handle error (show alert with information that the user has not granted your app access, etc.)
                                                }
                    }];
                }
                

                Now we can get the friends for an account using the GET friends/ids command:

                #import <Twitter/Twitter.h>
                
                -(void)getTwitterFriendsForAccount:(ACAccount*)account {
                    // In this case I am creating a dictionary for the account
                    // Add the account screen name
                    NSMutableDictionary *accountDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:account.username, @"screen_name", nil];
                    // Add the user id (I needed it in my case, but it's not necessary for doing the requests)
                    [accountDictionary setObject:[[[account dictionaryWithValuesForKeys:[NSArray arrayWithObject:@"properties"]] objectForKey:@"properties"] objectForKey:@"user_id"] forKey:@"user_id"];
                    // Setup the URL, as you can see it's just Twitter's own API url scheme. In this case we want to receive it in JSON
                    NSURL *followingURL = [NSURL URLWithString:@"http://api.twitter.com/1/friends/ids.json"];
                    // Pass in the parameters (basically '.ids.json?screen_name=[screen_name]')
                    NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:account.username, @"screen_name", nil];
                    // Setup the request
                    TWRequest *twitterRequest = [[TWRequest alloc] initWithURL:followingURL
                                                                parameters:parameters
                                                             requestMethod:TWRequestMethodGET];
                    // This is important! Set the account for the request so we can do an authenticated request. Without this you cannot get the followers for private accounts and Twitter may also return an error if you're doing too many requests
                    [twitterRequest setAccount:account];
                    // Perform the request for Twitter friends
                    [twitterRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
                                if (error) {
                                    // deal with any errors - keep in mind, though you may receive a valid response that contains an error, so you may want to look at the response and ensure no 'error:' key is present in the dictionary
                                }
                                NSError *jsonError = nil;
                                // Convert the response into a dictionary
                                NSDictionary *twitterFriends = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONWritingPrettyPrinted error:&jsonError];
                                // Grab the Ids that Twitter returned and add them to the dictionary we created earlier
                                [accountDictionary setObject:[twitterFriends objectForKey:@"ids"] forKey:@"friends_ids"];
                                NSLog(@"%@", accountDictionary);
                    }];
                }
                

                When you want the followers for an account, it's almost the same... Simple use the URL http://api.twitter.com/1/followers/ids.format and pass in the needed parameters as found via GET followers/ids

                Hope this gives you a good head start.

                UPDATE:

                As pointed out in the comments, you should be using the updated API call: https://api.twitter.com/1.1/followers/list.json

                這篇關于iPhone- Twitter API 獲取用戶關注者/關注者的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                How to animate a UIImageview to display fullscreen by tapping on it?(如何通過點擊動畫 UIImageview 以顯示全屏?)
                To stop segue and show alert(停止 segue 并顯示警報)
                iOS 5 storyboard, programmatically determine path(iOS 5 故事板,以編程方式確定路徑)
                Icon already includes gloss effects(圖標已經包含光澤效果)
                How does UIEdgeInsetsMake work?(UIEdgeInsetsMake 是如何工作的?)
                UIProgressView and Custom Track and Progress Images (iOS 5 properties)(UIProgressView 和自定義跟蹤和進度圖像(iOS 5 屬性))

                  <small id='4NPCF'></small><noframes id='4NPCF'>

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

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

                            <tbody id='4NPCF'></tbody>
                          主站蜘蛛池模板: 不锈钢法兰-碳钢法兰-法兰盘生产加工厂家-[鼎捷峰]-不锈钢法兰-碳钢法兰-法兰盘生产加工厂家-[鼎捷峰] | 色谱柱-淋洗液罐-巴罗克试剂槽-巴氏吸管-5ml样品瓶-SBS液氮冻存管-上海希言科学仪器有限公司 | 不锈钢丸厂家,铝丸,铸钢丸-淄博智源铸造材料有限公司 | 高防护蠕动泵-多通道灌装系统-高防护蠕动泵-www.bjhuiyufluid.com慧宇伟业(北京)流体设备有限公司 | 订做不锈钢_不锈钢定做加工厂_不锈钢非标定制-重庆侨峰金属加工厂 | 领先的大模型技术与应用公司-中关村科金 | 散热器-电子散热器-型材散热器-电源散热片-镇江新区宏图电子散热片厂家 | 餐饮加盟网_特色餐饮连锁加盟店-餐饮加盟官网 | 中视电广_短视频拍摄_短视频推广_短视频代运营_宣传片拍摄_影视广告制作_中视电广 | 过跨车_过跨电瓶车_过跨转运车_横移电动平车_厂区转运车_无轨转运车 | 贝壳粉涂料-内墙腻子-外墙腻子-山东巨野七彩贝壳漆业中心 | 临时厕所租赁_玻璃钢厕所租赁_蹲式|坐式厕所出租-北京慧海通 | 3dmax渲染-效果图渲染-影视动画渲染-北京快渲科技有限公司 | 焊锡,锡膏,锡线,锡条,焊锡膏-绿志岛金属有限公司 | 单锥双螺旋混合机_双螺旋锥形混合机-无锡新洋设备科技有限公司 | 咖啡加盟,咖啡店加盟连锁品牌-卡小逗 | 橡胶电子拉力机-塑料-微电脑电子拉力试验机厂家-江苏天源 | 苏州注册公司_苏州代理记账_苏州工商注册_苏州代办公司-恒佳财税 | 对夹式止回阀厂家,温州对夹式止回阀制造商--永嘉县润丰阀门有限公司 | 外贸网站建设-外贸网站设计制作开发公司-外贸独立站建设【企术】 | 皮带式输送机械|链板式输送机|不锈钢输送机|网带输送机械设备——青岛鸿儒机械有限公司 | 宽带办理,电信宽带,移动宽带,联通宽带,电信宽带办理,移动宽带办理,联通宽带办理 | 河南生物显微镜,全自动冰冻切片机-河南荣程联合科技有限公司 | DDoS安全防护官网-领先的DDoS安全防护服务商 | 耐破强度测试仪-纸箱破裂强度试验机-济南三泉中石单品站 | 保温杯,儿童婴童奶瓶,运动水壶「广告礼品杯定制厂家」超朗保温杯壶 | 合肥展厅设计-安徽展台设计-合肥展览公司-安徽奥美展览工程有限公司 | 坏男孩影院-提供最新电影_动漫_综艺_电视剧_迅雷免费电影最新观看 | SDI车窗夹力测试仪-KEMKRAFT方向盘测试仪-上海爱泽工业设备有限公司 | 深圳货架厂_仓库货架公司_重型仓储货架_线棒货架批发-深圳市诺普泰仓储设备有限公司 | 知网论文检测系统入口_论文查重免费查重_中国知网论文查询_学术不端检测系统 | 广州网站建设_小程序开发_番禺网站建设_佛山网站建设_粤联网络 | 澳门精准正版免费大全,2025新澳门全年免费,新澳天天开奖免费资料大全最新,新澳2025今晚开奖资料,新澳马今天最快最新图库-首页-东莞市傲马网络科技有限公司 | jrs高清nba(无插件)直播-jrs直播低调看直播-jrs直播nba-jrs直播 上海地磅秤|电子地上衡|防爆地磅_上海地磅秤厂家–越衡称重 | 碳刷_刷握_集电环_恒压簧_电刷厂家-上海丹臻机电科技有限公司 | 水厂污泥地磅|污泥处理地磅厂家|地磅无人值守称重系统升级改造|地磅自动称重系统维修-河南成辉电子科技有限公司 | EDLC超级法拉电容器_LIC锂离子超级电容_超级电容模组_软包单体电容电池_轴向薄膜电力电容器_深圳佳名兴电容有限公司_JMX专注中高端品牌电容生产厂家 | 台湾阳明固态继电器-奥托尼克斯光电传感器-接近开关-温控器-光纤传感器-编码器一级代理商江苏用之宜电气 | 精密模具-双色注塑模具加工-深圳铭洋宇通 | 色油机-色母机-失重|称重式混料机-称重机-米重机-拌料机-[东莞同锐机械]精密计量科技制造商 | 冷轧机|两肋冷轧机|扁钢冷轧机|倒立式拉丝机|钢筋拔丝机|收线机-巩义市华瑞重工机械制造有限公司 |