ios – 获取推特朋友列表?

我在twitter friends / list API中收到了Bad Authentication数据响应.登录时我收到用户ID,屏幕名称,authToken和authTokenSecret.

func loadFollowers(userid:String) {

    //let twapi = "https://api.twitter.com/1.1/followers/list.json?cursor=-1&user_id=\(session)&count=5000"
    let twapi = "https://api.twitter.com/1.1/friends/list.json?cursor=-1&user_id=\(userid)&count=10"
    let url2 = URL(string: twapi)!
    print(url2)
    URLSession.shared.dataTask(with: url2,completionHandler: { (data,response,error) in

    //UIApplication.shared.isNetworkActivityIndicatorVisible = false
        do {
            let userData = try JSONSerialization.jsonObject(with: data!,options:[])
            print(userData)
        } catch {
            NSLog("Account Information could not be loaded \(error)")
        }
    }).resume()
}

输出:

{
"errors": [
    {
        "code": 215,"message": "Bad Authentication data."
    }
]
}

在friends / list.json API中发送的必需参数是什么.
在本文档中,他们给出的所有参数都是可选的
https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-friends-list

解决方法

因为这个friends / list api需要身份验证才能获取朋友list.

Requires Authentication: Yes

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...