Skip to content

Instantly share code, notes, and snippets.

@jmoz
Last active December 14, 2015 04:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmoz/5030012 to your computer and use it in GitHub Desktop.
Save jmoz/5030012 to your computer and use it in GitHub Desktop.
An example of client code and XML response from LinkedIn's network_updates endpoint. The access tokens used have requested the rw_nus permission.
from linkedin import linkedin
import config
li = linkedin.LinkedIn(config.Linkedin.API_KEY, config.Linkedin.API_SECRET, 'http://foo.com')
"""the network_updates endpoint needs rw_nus permission, so do something like this during oauth flow:
li.request_token(['rw_nus', 'r_fullprofile'])
"""
li._access_token = config.Linkedin.OAUTH_TOKEN
li._access_token_secret = config.Linkedin.OAUTH_SECRET
print li.network_updates(scope='self', types=['CONN', 'SHAR'], count=2)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<updates total="21" count="2" start="0">
<update>
<timestamp>1361801106553</timestamp>
<update-key>UNIU-21666666-5711807828415508480-SHARE</update-key>
<update-type>SHAR</update-type>
<update-content>
<person>
<id>BJljnMHtuv</id>
<first-name>James</first-name>
<last-name>Morris</last-name>
<headline>PHP, Symfony2, Python web programmer (contract). Previous experience at TimeOut, BSkyB, IPC Media.</headline>
<current-share>
<id>s1384978476</id>
<timestamp>1361801106553</timestamp>
<visibility>
<code>anyone</code>
</visibility>
<comment>Updated python-linkedin with support for permissions and the network_updates endpoint http://lnkd.in/hZgiei</comment>
<content>
<submitted-url>https://github.com/jmoz/python-linkedin</submitted-url>
<shortened-url>http://lnkd.in/hZgiei</shortened-url>
<title>python-linkedin</title>
<description>python-linkedin. Contribute to python-linkedin development by creating an account on GitHub.</description>
<eyebrow-url>http://www.linkedin.com/share?viewLink=&amp;sid=s1384978476&amp;url=http%3A%2F%2Flnkd%2Ein%2FhZgiei&amp;urlhash=zQbp&amp;uid=5711807828415508480</eyebrow-url>
</content>
<source>
<service-provider>
<name>LINKEDIN</name>
</service-provider>
</source>
<author>
<id>BJljnMHtuv</id>
<first-name>James</first-name>
<last-name>Morris</last-name>
<headline>PHP, Symfony2, Python web programmer (contract). Previous experience at TimeOut, BSkyB, IPC Media.</headline>
</author>
</current-share>
<picture-url>http://m3.licdn.com/mpr/mprx/0_lwfCFP7zNHngbiuc1epAFr0BNel-5LDcPERjFrpWwa5GsTVBjS0mWKebs5AD6G2RKeDyHBCkuTG4</picture-url>
<api-standard-profile-request>
<url>http://api.linkedin.com/v1/people/BJljnMHtuv</url>
<headers total="1">
<http-header>
<name>x-li-auth-token</name>
<value>name:sV9_</value>
</http-header>
</headers>
</api-standard-profile-request>
<site-standard-profile-request>
<url>http://www.linkedin.com/profile/view?id=21666666&amp;authType=name&amp;authToken=sV9_&amp;trk=api*a249349*s257207*</url>
</site-standard-profile-request>
</person>
</update-content>
<is-commentable>true</is-commentable>
<update-comments total="0" />
<is-likable>true</is-likable>
<is-liked>false</is-liked>
<num-likes>0</num-likes>
</update>
<update>
<timestamp>1361790686000</timestamp>
<update-key>CONN-21666666-*2-*1</update-key>
<update-type>CONN</update-type>
<update-content>
<person>
<id>BJljnMHtuv</id>
<first-name>James</first-name>
<last-name>Morris</last-name>
<headline>PHP, Symfony2, Python web programmer (contract). Previous experience at TimeOut, BSkyB, IPC Media.</headline>
<connections total="1">
<person>
<id>tFgLTrNHw9</id>
<first-name>some</first-name>
<last-name>guy</last-name>
<headline>Wed Developer</headline>
<picture-url>http://m3.licdn.com/mpr/mprx/0_WTL7meSxOYOkJ1PIwFqymoHx-yIwMzPIIQArmIoxDV0UQlkwLbz_hwYlplwNV-tFeCFlTuNWyHdi</picture-url>
<api-standard-profile-request>
<url>http://api.linkedin.com/v1/people/tFgLTrNHw9</url>
<headers total="1">
<http-header>
<name>x-li-auth-token</name>
<value>name:Cl8y</value>
</http-header>
</headers>
</api-standard-profile-request>
<site-standard-profile-request>
<url>http://www.linkedin.com/profile/view?id=190749300&amp;authType=name&amp;authToken=Cl8y&amp;trk=api*a249349*s257207*</url>
</site-standard-profile-request>
</person>
</connections>
<picture-url>http://m3.licdn.com/mpr/mprx/0_lwfCFP7zNHngbiuc1epAFr0BNel-5LDcPERjFrpWwa5GsTVBjS0mWKebs5AD6G2RKeDyHBCkuTG4</picture-url>
<api-standard-profile-request>
<url>http://api.linkedin.com/v1/people/BJljnMHtuv</url>
<headers total="1">
<http-header>
<name>x-li-auth-token</name>
<value>name:sV9_</value>
</http-header>
</headers>
</api-standard-profile-request>
<site-standard-profile-request>
<url>http://www.linkedin.com/profile/view?id=21666666&amp;authType=name&amp;authToken=sV9_&amp;trk=api*a249349*s257207*</url>
</site-standard-profile-request>
</person>
</update-content>
<is-commentable>false</is-commentable>
<is-likable>false</is-likable>
</update>
</updates>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment