LinkedIn API-如何查询连接总数? [英] LinkedIn API - how to query for the total number of connections?
问题描述
我正在尝试查询这样的连接总数:
I am trying to query for the total number of connections like this:
/people/id=QM86-RIKjb:(connections total)
并在此处使用API示例: https://developer.linkedin.com/documents/profile -api
and using the API example here: https://developer.linkedin.com/documents/profile-api
在底部的xml示例中显示此字段:<connections total="" >
in the xml example towards the bottom the show this field: <connections total="" >
我正在尝试查询它,但出现异常,因为我的URI错误:
I am trying to query for it, but I get an exception that I have a bad URI:
URI::InvalidURIError: bad URI(is not URI?): /v1/people/id=QM86-RIKjb:(connections total)
我做错了什么?是否有查询此类参数的正确方法?
What am I doing incorrectly? Is there a correct way to query for such parameters?
谢谢!
推荐答案
要从个人资料API ,您可以直接询问API:
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>
请记住,查看用户可以使用的字段受到限制-请检查配置文件字段文档以获取详细信息.例如,不可能获得连接的连接"-如果在上面的示例中nbqwYraDfd
代表当前的查看用户,则可以使用:
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)
哪个会返回:
<?xml version="1.0" encoding="UTF-8"?>
<person>
<connections total="XXX" count="YYY" start="0">
<person>
...
</person>
</connections>
</person>
然后遍历XML(取决于语言)来检查total的值.
And then check the value of total by traversing the XML (language dependant).
但是,如果nbqwYraDfd
是当前用户的连接或非连接,您将收到403响应:
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>
这篇关于LinkedIn API-如何查询连接总数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!