|
| 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 |
0 commit comments