【问题标题】:How to do people search based on keywords using linkedin api in R?如何在R中使用linkedin api根据关键字进行人们搜索?
【发布时间】:2015-03-02 23:56:11
【问题描述】:

我正在尝试根据关键字提取个人资料搜索数据。它显示访问被拒绝。

1) 如何在 R 中使用linkedin api 获取人们搜索数据? (但我在 apigee 休息控制台上获取数据)。

2) 在 R 中将 XML 数据存储为 Data Frame 的最佳方式是什么?当根节点之间的行不同时?

下面是我的代码。

library(httr)
library(XML)

oauth_endpoints("linkedin")

myapp <- oauth_app("Profile Search", key  = "785mvlu4741k9o", secret="DMRmtjDfFo4ncLzg")

TokenLinkedIn <- R6::R6Class("TokenLinkedIn", inherit = Token2.0, list(
  sign = function(method, url) {
    url <- parse_url(url)
    url$query$oauth2_access_token <- self$credentials$access_token
    list(url = build_url(url), config = config())
  },
  can_refresh = function() {
    TRUE
  },
  refresh = function() {
    self$credentials <- init_oauth2.0(self$endpoint, self$app,
                                      scope = self$params$scope, type = self$params$type,
                                      use_oob = self$params$use_oob)
  }
))

token <- TokenLinkedIn$new(
  endpoint = oauth_endpoints("linkedin"),
  app = myapp,
  params = list(use_oob = FALSE, scope = NULL, type = NULL)
)

homeTL<- GET("https://api.linkedin.com/v1/people-search:(people:(first-name,last-name,headline,industry,email-address))?keywords=client%20engagement"
, config(token = token))

homeTL
# I am getting below error message as Access to people search denied.
#<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
#<error>
  #<status>403</status>
  #<timestamp>1425299488038</timestamp>
  #<request-id>JXQYYV5V0Z</request-id>
  #<error-code>0</error-code>
  #<message>Access to people search denied.</message>
# </error>


doc <- xmlTreeParse(homeTL,useInternal=TRUE)
rootNode <- xmlRoot(doc)
Id<-xpathSApply(rootNode,"//id", xmlValue)
firstname<-xpathSApply(rootNode,"//first-name", xmlValue)
lastname<-xpathSApply(rootNode,"//last-name", xmlValue)
industry<-xpathSApply(rootNode,"//industry", xmlValue)

Link=data.frame("Id"=Id,"FirstName"=firstname,"LastName"=lastname)

## While including industry rows showing error 
#Error in data.frame(Id = Id, FirstName = firstname, LastName = lastname,  : 
  #                    arguments imply differing number of rows: 842, 786 

【问题讨论】:

    标签: r linkedin httr


    【解决方案1】:

    【讨论】:

    • 但是请注意,这要到 2015 年 5 月 12 日才会生效。
    • @JustinKominar 我无法理解。有可能吗?
    • @KaramChand 是的 - 目前有可能。但正如最初的评论所提到的,5 月 12 日之后的情况将不再如此。但是,我没有特定的 R 经验来帮助您解决最初的问题。我只是想让你知道,你想要做的事情不会再长久了。
    • 人物搜索限制现已到位。但是,该限制适用于每天执行呼叫超过 250 次的人。如果您每天确实有超过 250 次访问,则必须获得特别许可。见这里 (developer-programs.linkedin.com/blog/vetted-api-access)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-11
    • 2015-10-06
    • 2012-10-09
    • 2022-01-14
    相关资源
    最近更新 更多