bear / python-twitter

A Python wrapper around the Twitter API.
Apache License 2.0
3.41k stars 955 forks source link

Need help for /1.1/users/lookup request #675

Open msohaibali opened 3 years ago

msohaibali commented 3 years ago

I am trying to do request on users/lookup route of Twitter API using params of Email/Phone. In the result I am getting error Could not authenticate you. in response

While using the same credentials when i do request for screen_name, user_id lookup I am getting perfect Response. Not only that all other api requests like home_timeline, followers_ids, friends_ids, etc are working fine with same credentials but on that specific request, I am getting this error. My Request is:

import requests

url = "https://api.twitter.com/1.1/users/lookup.json?map=true&phone=1234567890"

payload = {}

headers = {
    'Authorization': 'OAuth realm="http%3A%2F%2Fapi.twitter.com",oauth_consumer_key="<consumer_key>",oauth_token="<outh_token>",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1595318479",oauth_nonce="<nonce>",oauth_version="1.0",oauth_signature="<sig>"'
}

response = requests.request("GET", url, headers=headers, data = payload)
print(response.text.encode('utf8'))

In Response I am getting this Error:

{
    "errors": [
        {
            "code": 32,
            "message": "Could not authenticate you."
        }
    ]
}

What are the reasons and suggestions on this ? Will appreciate the positive feedback.