Skip to content

Commit 50fcb2b

Browse files
committed
Add LinkedIn example
1 parent 3326812 commit 50fcb2b

File tree

5 files changed

+115
-1
lines changed

5 files changed

+115
-1
lines changed

credentials - example.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,10 @@ Salesforce
2525
Facebook
2626
# Url: developers.facebook.com
2727
- id: Your App Id
28-
- secret: Your App Secret
28+
- secret: Your App Secret
29+
30+
LinkedIn
31+
- api_key: Your API key
32+
- api_secret: Your API secret
33+
- user_token: Your user token
34+
- user_secret: Your user secret

examples/Excel-REST - Example.xlsm

-25.9 KB
Binary file not shown.

examples/linkedin/LinkedIn.bas

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
Attribute VB_Name = "LinkedIn"
2+
Private pLinkedInClient As RestClient
3+
Private pLinkedInAPIKey As String
4+
Private pLinkedInAPISecret As String
5+
Private pLinkedInUserToken As String
6+
Private pLinkedInUserSecret As String
7+
8+
Private Property Get LinkedInAPIKey() As String
9+
If pLinkedInAPIKey = "" Then
10+
If Credentials.Loaded Then
11+
pLinkedInAPIKey = Credentials.Values("LinkedIn")("api_key")
12+
Else
13+
pLinkedInAPIKey = InputBox("Please Enter LinkedIn API Key")
14+
End If
15+
End If
16+
17+
LinkedInAPIKey = pLinkedInAPIKey
18+
End Property
19+
20+
Private Property Get LinkedInAPISecret() As String
21+
If pLinkedInAPISecret = "" Then
22+
If Credentials.Loaded Then
23+
pLinkedInAPISecret = Credentials.Values("LinkedIn")("api_secret")
24+
Else
25+
pLinkedInAPISecret = InputBox("Please Enter LinkedIn API Secret")
26+
End If
27+
End If
28+
29+
LinkedInAPISecret = pLinkedInAPISecret
30+
End Property
31+
32+
Private Property Get LinkedInUserToken() As String
33+
If pLinkedInUserToken = "" Then
34+
If Credentials.Loaded Then
35+
pLinkedInUserToken = Credentials.Values("LinkedIn")("user_token")
36+
Else
37+
pLinkedInUserToken = InputBox("Please Enter LinkedIn User Token")
38+
End If
39+
End If
40+
41+
LinkedInUserToken = pLinkedInUserToken
42+
End Property
43+
44+
Private Property Get LinkedInUserSecret() As String
45+
If pLinkedInUserSecret = "" Then
46+
If Credentials.Loaded Then
47+
pLinkedInUserSecret = Credentials.Values("LinkedIn")("user_secret")
48+
Else
49+
pLinkedInUserSecret = InputBox("Please Enter LinkedIn User Secret")
50+
End If
51+
End If
52+
53+
LinkedInUserSecret = pLinkedInUserSecret
54+
End Property
55+
56+
Private Property Get LinkedInClient() As RestClient
57+
If pLinkedInClient Is Nothing Then
58+
Set pLinkedInClient = New RestClient
59+
pLinkedInClient.BaseUrl = "http://api.linkedin.com/v1/"
60+
61+
Dim Auth As New OAuth1Authenticator
62+
Auth.Setup _
63+
ConsumerKey:=LinkedInAPIKey, _
64+
ConsumerSecret:=LinkedInAPISecret, _
65+
Token:=LinkedInUserToken, _
66+
TokenSecret:=LinkedInUserSecret
67+
Set pLinkedInClient.Authenticator = Auth
68+
End If
69+
70+
Set LinkedInClient = pLinkedInClient
71+
End Property
72+
73+
Public Function GetProfile(Optional Callback As String = "") As RestResponse
74+
Dim Request As New RestRequest
75+
Request.Resource = "people/~?format={format}"
76+
77+
If Callback <> "" Then
78+
LinkedInClient.ExecuteAsync Request, Callback
79+
Else
80+
Set GetProfile = LinkedInClient.Execute(Request)
81+
End If
82+
End Function
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
VERSION 1.0 CLASS
2+
BEGIN
3+
MultiUse = -1 'True
4+
END
5+
Attribute VB_Name = "LinkedInSheet"
6+
Attribute VB_GlobalNameSpace = False
7+
Attribute VB_Creatable = False
8+
Attribute VB_PredeclaredId = True
9+
Attribute VB_Exposed = True
10+
Public Sub LoadProfile()
11+
Me.[LinkedInFirstName] = "Loading Async..."
12+
Me.[LinkedInLastName] = ""
13+
Me.[LinkedInHeadline] = ""
14+
15+
LinkedIn.GetProfile "LinkedInSheet.LoadedProfile"
16+
End Sub
17+
18+
Public Sub LoadedProfile(Response As RestResponse)
19+
If Response.StatusCode = 200 Then
20+
Me.[LinkedInFirstName] = Response.Data("firstName")
21+
Me.[LinkedInLastName] = Response.Data("lastName")
22+
Me.[LinkedInHeadline] = Response.Data("headline")
23+
Else
24+
Me.[LinkedInFirstName] = "Error: " & Response.Content
25+
End If
26+
End Sub

specs/Excel-REST - Specs.xlsm

70.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)