emorikawa / linkedin-oauth2

Ruby wrapper for the LinkedIn OAuth2 API
Other
70 stars 86 forks source link

How do I get the JSON output for the API? #10

Open fluke opened 10 years ago

fluke commented 10 years ago

According to the LinkedIn API:

Indicating you want to use JSON or JSONP

You can retrieve JSON data using the new "format" parameter:

GET https://api.linkedin.com/v1/people/~:(id)?format=json

You can also tell us you want JSON by sending a HTTP header of x-li-format with a value of json.

x-li-format: json Now you receive JSON-formatted data from API calls instead of the default format of XML.

There doesn't seem to be anything documented for this. But it seems like it'd be easy to implement.

fluke commented 10 years ago

Actually it seems that you're requesting json and converting it to a ruby hash. My bad. Is there a way to turn this off it I want to work with the json?

mordof-work commented 9 years ago

This issue is quite old, but just in case anyone else comes across it:

https://github.com/emorikawa/linkedin-oauth2/blob/master/lib/linked_in/api_resource.rb#L44-L50

I imagine all you'd need to do is overwrite the get method there, and do everything the same expect return just the response.body (without converting)