Resource id #2 réponse de curl de php
Je suis en train d'interpréter cette ligne de commande dans curl de php
commande curl:
curl https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "{clientId}:{secret}" \
-d "grant_type=client_credentials"
Voici mon curl de php code:
$url = 'https://api.sandbox.paypal.com/v1/oauth2/token';
$info = array(
'grant_type' =>'client_credentials'
);
$post_field_string = http_build_query($info, '', '&');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept-Language: en_US')
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD,'AQHeHhDPIpAoxWaNkXOwCNFV4cZUobhqDa_4qHPKh0iDrSd6rLaxIknT-lmgwd:EJHLmhBMT9dB48kou4V0jyJzaq-CqUlY0zS6QKsxOZKI15hZHZjTfoSV7MO8we');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_field_string );
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
$exec = curl_exec($ch);
curl_exec($ch);
curl_close($ch);
Et j'obtiens ce résultat:
Resource id #2
Je suis nouveau sur curl mais je suis en train de l'étudier. Est-ce le bon code dans mon curl de php?
J'attends cet exemple de réponse de curl:
{
"scope": "https://api.paypal.com/v1/payments/.* https://api.paypal.com/v1/vault/credit-card https://api.paypal.com/v1/vault/credit-card/.*",
"access_token": "EEwJ6tF9x5WCIZDYzyZGaz6Khbw7raYRIBV_WxVvgmsG",
"token_type": "Bearer",
"app_id": "APP-6XR95014BA15863X",
"expires_in": 28800
}
OriginalL'auteur user3391620 | 2014-06-04
Vous devez vous connecter pour publier un commentaire.
Essayez ce code:
CURLOPT_HTTPHEADER
n'est pas nécessaire si vous êtes de passage à un tableau ou une chaîne.Ajouté
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
de pontage SSLcurl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
Réponse:
Vous êtes les bienvenus, vous pouvez vérifier ici sur la façon d'upvote : meta.stackexchange.com/questions/173399/...
OriginalL'auteur Vimalnath