LinkedIn API - how to query for the total number of connections?

前端 未结 2 1526
挽巷
挽巷 2021-01-20 05:48

I am trying to query for the total number of connections like this:

/people/id=QM86-RIKjb:(connections total)

and using the API example her

相关标签:
2条回答
  • 2021-01-20 06:21

    To get the connection count from the Profile API, you can ask the API directly:

    http://api.linkedin.com/v1/people/id=nbqwYraDfd:(num-connections,num-connections-capped)

    Which will return (depending on the connection count):

    <?xml version="1.0" encoding="UTF-8"?>
    <person>
      <num-connections>500</num-connections>
      <num-connections-capped>true</num-connections-capped>
    </person>
    

    Keep in mind that there are restrictions on the fields available to the viewing user - check the Profile Fields document for details. For instance, it is not possible to get 'connections of connections' - if, in your example above, nbqwYraDfd represents the current viewing user, you can use:

    http://api.linkedin.com/v1/people/id=nbqwYraDfd:(connections)

    Which will return:

    <?xml version="1.0" encoding="UTF-8"?>
    <person>
      <connections total="XXX" count="YYY" start="0">
        <person>
        ...
        </person>
      </connections>
    </person>
    

    And then check the value of total by traversing the XML (language dependant).

    However, if nbqwYraDfd is a connection of the current user, or a non-connection, you will get a 403 response:

    <?xml version="1.0" encoding="UTF-8"?>
    <error>
      <status>403</status>
      <timestamp>1337954306491</timestamp>
      <request-id>25P44ZN249</request-id>
      <error-code>0</error-code>
      <message>Access to other member's connections denied</message>
    </error>
    
    0 讨论(0)
  • 2021-01-20 06:28

    You cannot do this ( you cannot get an attribute of a particular tag)

    Do this,

    http://api.linkedin.com/v1/people/id=nbqwYraDfd:(connections)
    

    Get the response returned and parse the XML returned in your programming language and read the attribute total of connections tag.

    If you are interested in getting total count only, I would suggest this query to filter the response returned,

    http://api.linkedin.com/v1/people/id=nbqwYraDfd:(connections:())
    

    Which programming language are you using, may be I can help in parsing the XML returned.

    0 讨论(0)
提交回复
热议问题