I'm trying to convert this code from an api it is written in python and I have a feeling that it can be converted to php. I tried to learn python, have some research but I think it's a long road to learn python. I also search some example of converting python to php but still have no luck to make it work. Please help if you have ideas about this. thanks
import requests
# Get a new OAUth2 token
response = requests.post('http://ift.tt/2fpFo2U', data={
'response_type': 'token',
'client_id': 'YOUR_API_KEY',
'scope': 'history user_identity', # Optional
'redirect_uri': 'http://example.com', # Must be the same as defined in dashboard
})
# Grab the token from the response URL
token = re.findall(
r'access_token=(.*)&token_type',
response.headers.get('Location')
)[0]
# Use it for your requests
response = self.client.get(
'api/v2/sellorder',
headers={'Authorization': 'Bearer {}'.format(token)}
)
Aucun commentaire:
Enregistrer un commentaire