ozgur / python-linkedin

Python interface to the LinkedIn API
http://ozgur.github.com/python-linkedin/
MIT License
889 stars 394 forks source link

Trying to get a user profile using public URL - LinkedInError: 400 Client Error: Bad Request #53

Open Michelcyc opened 10 years ago

Michelcyc commented 10 years ago

I'm not managing to get the results from a profile using it's URL.

Basically I'm trying to use that request: application.get_profile(member_url='http://www.linkedin.com/profile/view?id=238343623&authType=name&authToken=LMsx&trk=api*a3334503*s3406633*')

I also tried to use only: application.get_profile(member_url='http://www.linkedin.com/profile/view?id=238343623')

Didn't work either, same error

Everything is working, I get a response using no parameters or the 'user id' as parameter, but I need to use the 'user public URL' to my searches.

Best Regards Michel

ozgur commented 10 years ago

First of all, Is this user your connection? Because, otherwise you may not be permitted to see their profile.

If so; have you tried the following?

api.get_profile(member_id='238343623')
Michelcyc commented 10 years ago

The user is my second degree connection. And I tried the code you showed even using my own id, but just using the id numbers from the profile doesn't work, to use the member_id selector you need to get the id using some other search... Like my id in the profile page is 238343623, but my id actually is 'PLZGyPYO8P'.

So, the method get_profile() works using: -No parameters -Parameter - member_id='PLZGyPYO8P'

But when I try to use the parameter member_url I really can't find the right URL for input, but I'm working on it, I'll feedback if I discover the problem

Michelcyc commented 10 years ago

Hey ozgur I was reading the LinkedIn API forum and I found the right type of input in this page, that would be:

GET /v1/people/url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fantoniogomes?oauth2_access_token=****

As you see there is a '?' there that is not url-escaped and the get_profile method in the wrapper executes url_escaping in all the content from the member_url parameter:

urllib.quote_plus(member_url)

I still don't know how to make a GET request myself without using this wrapper, but I think what I'll need to do is try to take the access token of the link that comes from the profile returned by the member_id and put it in the oauth2_access_token parameter right?

Like taking this:

LMsx&trk=api_a3334503_s3406633*

From this:

http://www.linkedin.com/profile/view?id=238343623&authType=name&authToken=LMsx&trk=api*a3334503*s3406633*

And inserting like that:

api.get_profile(member_url='http://www.linkedin.com/profile/view?id=238343623&authType=name&oauth2_access_token=LMsx&trk=api*a3334503*s3406633*')

As I still doesn't know how to make a request off of this library I can't test my theory I'm stucked, plz help =)

svlada commented 9 years ago

@Michelcyc Hi, did you managed to solve your problem? I'm facing similar issues.

I am getting the following exception after invoking

app.get_profile(member_url="https://www.linkedin.com/profile/view?id=27451049")
Traceback (most recent call last):
  File "api.py", line 47, in <module>
    start()
  File "api.py", line 43, in start
    profile = app.get_profile(member_url="https://www.linkedin.com/profile/view?id=27451049")
  File "C:\Python27\lib\site-packages\linkedin\linkedin.py", line 179, in get_profile
    raise_for_error(response)
  File "C:\Python27\lib\site-packages\linkedin\utils.py", line 63, in raise_for_error
    raise LinkedInError(message)
linkedin.exceptions.LinkedInError: 400 Client Error: Bad Request: Unknown Error
Michelcyc commented 9 years ago

@svlada I started reading the code from the repository until I noticed that the .get_profile(member_url) from this wrapper isn´t doing the conversion(url_escaping) properly... as told in the post above. If you had the same problem, which means it persists I assume no changes were made despite my reports. I didn´t solve the problem. Instead I used .get_profile(member_id) this method is working properly. You can get the parameter member_id using the Search API, asking for the id in the selectors.

svlada commented 9 years ago

@Michelcyc Search API is not permitted to everyone, and I have a list of profile urls. For example: https://www.linkedin.com/profile/view?id=27451049.

It seems that id value from URL above is not member_id.

Is there any way to get real member_id without using Search API?

Michelcyc commented 9 years ago

=/ the method .get_profile(member_url) would be perfect for you, if it worked... Sorry I can´t help with that... You can ask for permission to use the Search API if you want, just fill a form in their website, it´s easy to have some limited access... 500 searchs a day, I don´t remember the limits really... but I don´t think you want this either.

I would suggest you to learn how to use the LinkedIn API without this wrapper. It can be more difficult, but maybe it´s what you need... I remember reading this wrapper´s code, trying to extend it to implement a new member_url method, but I just gave up after some time. Good luck !

kaushal66 commented 9 years ago

How can view linkedIn users profile by id (huwY24VU2K) this ID i have got from invitation plugin