当前位置 : 主页 > 手机开发 > ios >

ios – 获取推特朋友列表?

来源:互联网 收集:自由互联 发布时间:2021-06-11
我在twitter friends / list API中收到了Bad Authentication数据响应.登录时我收到用户ID,屏幕名称,authToken和authTokenSecret. func loadFollowers(userid:String) { //let twapi = "https://api.twitter.com/1.1/followers/list.js
我在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
网友评论