Search code examples
ruby-on-railsapilinkedin-apirest-client

Check Linkedin id is valid in Ruby on Rails


I have linkedin Id. I need to check whether it is valid id using rest client or similar to that. I don't want to fetch data or some other stuffs for that id. I need to do this in Ruby on rails. Can anyone please guide me in detail?


Solution

  • I'm not familiar with LinkedIn API, but the simplest solution would be to query the website directly and check the status code of the response.

    For example, using the Faraday gem:

    res = Faraday.get('http://www.linkedin.com/in/' + person_id)
    if res.status == 200
      ...
    end
    

    The disadvantage of this approach is that the entire webpage is fetched every time, even if you only check the status. You can probably find a similar call to the LinkedIn API which would return less data.