2

I am trying to get the share count from this Linkedin API call using HTTParty in Rails, but it doesn't seems to properly be parsing and obtaining data. Why is that?

count = JSON.parse(HTTParty.get('https://www.linkedin.com/countserv/count/share?url=' + url + '&format=json')["count"]

1 Answer 1

3

You should use body attribute instead of the return value of the get (HTTParty::Response).

url = 'https://www.linkedin.com/countserv/count/share?url=' + url + '&format=json'
count = JSON.parse(HTTParty.get(url).body)["count"]
#                                   ^^^^^
Sign up to request clarification or add additional context in comments.

2 Comments

@user2270029, What is the value of the url?
It worked when I restarted my rails server. Thanks for your help.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.