有没有一种方法可以限制从GET / me / accounts返回的字段?

时间:2019-07-05 18:01:02

标签: facebook-graph-api

当我使用'GET / me / accounts'返回用户所管理的页面列表时,我得到了太多的数据,这些数据对于许多不相关的字段使用相同的标识符(即,“名称”用于类别和页面名称)。这使得几乎不可能解析数据。有没有一种方法可以限制api返回的内容,所以我只获得页面名称,页面ID和页面访问令牌的列表?

我正在使用RestSharp进行api调用,如下所示:

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim usertoken As String = hiddenuseraccesstoken.Value

        Dim client As New RestClient("https://graph.facebook.com")
        Dim pagesrequest = New RestRequest("/me/accounts" & "?access_token=" & usertoken, Method.GET)
        Dim response As IRestResponse = client.Execute(pagesrequest)
        Dim textresponse As String = response.Content
        TextBox2.Text = textresponse
    End Sub

响应为:

"{"data":[{"access_token":"XXXXXXXXXXXXXXXXXXXXXXXXX","category":"Real Estate Agent","category_list":[{"id":"555559023685716","name":"Real Estate Agent"},{"id":"5555518281071392","name":"Local Service"}],"name":"Realtor Group","id":"444448043920986","tasks":["ANALYZE","ADVERTISE","MODERATE","CREATE_CONTENT","MANAGE"]}],"paging":{"cursors":{"before":"ODk1MDE4MDQzOTIwOTg2","after":"ODk1MDE4MDQzOTIwOTg2"}}}"

我只需要页面名称,页面ID和页面访问令牌。有没有一种方法可以限制api返回的内容,这就是我得到的?

1 个答案:

答案 0 :(得分:0)

您可以利用声明性字段来做到这一点:

/me/accounts?fields=name,id,access_token