[Zend_Http] Probleme pour utiliser Curl
Bonjour à tous je souhaite remplacer ce code qui fonctionne parfaitement :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| <?php
$rpxApiKey = 'REPLACE_WITH_YOUR_RPX_API_KEY';
if(isset($_POST['token'])) {
$token = $_POST['token'];
/* Use the token to make the auth_info API call */
$post_data = array('token' => $_POST['token'],
'apiKey' => $rpxApiKey,
'format' => 'json');
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, 'https://rpxnow.com/api/v2/auth_info');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$raw_json = curl_exec($curl); curl_close($curl);
/* STEP 3: Parse the JSON auth_info response */
$auth_info = json_decode($raw_json, true);
if ($auth_info['stat'] == 'ok') {
/* STEP 3 Continued: Extract the 'identifier' from the response */
$profile = $auth_info['profile'];
// etc...
}
}
?> |
Par ce code qui ne fonctionne pas xD . L'erreur retourné est une erreur au niveau du passage de clé d'api qui n'est apparement pas transmis, bien que configuré ici : CURLOPT_POSTFIELDS => $post_data , de la même façon que le code ci-dessous.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| <?php
$uri = 'https://rpxnow.com/api/v2/auth_info';
$rpxApiKey = 'REPLACE_WITH_YOUR_RPX_API_KEY';
if(isset($this->getRequest()->getPost('token')) {
$token = $this->getRequest()->getPost('token'), ;
$post_data = array('token' => $_POST['token'],
'apiKey' => $rpxApiKey,
'format' => 'json');
/* Use the token to make the auth_info API call */
$config = array(
'adapter' => 'Zend_Http_Client_Adapter_Curl',
'curloptions' => array(CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => 'https://rpxnow.com/api/v2/auth_info',
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $post_data,
CURLOPT_HEADER => false,
CURLOPT_SSL_VERIFYPEER => false),
);
$client = new Zend_Http_Client($uri, $config);
$result = $client->request();
$auth_info = json_decode($result, true);
if ($auth_info['stat'] == 'ok') {
/* STEP 3 Continued: Extract the 'identifier' from the response */
$profile = $auth_info['profile'];
// etc...
}
}
?> |
Quelqu'un à t-il une idée? Merci d'avance pour votre aide.