• 0
Sign in to follow this  
fabiogomez28

autentication return empty acces token

Question

hi . 
 
I had the problem with authentication when requesting the access token. the server returned me
 

Array
(
[access_token] =>
[expires_in] => 1402341901
[refresh_token] =>
)

 

I am using PHP SDK and the parameter APP_ID,SECRET_KEY ,REDIRECT_URI  were well ,i think  the problem was in the curl configuration,i decide  print the error in the function execute of mail.php using  curl_error

 

public function execute($path, $opts = array(), $params = array()) {
        $uri = $this->make_path($path, $params);
 
        $ch = curl_init($uri);
        curl_setopt_array($ch, self::$CURL_OPTS);
 
 
        if(!empty($opts))
            curl_setopt_array($ch, $opts);
   
$response = curl_exec($ch);
//print error
$error = curl_error($ch);
echo $error;
print_r($response);
        $return["body"] = json_decode($response);
        $return["httpCode"] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
        curl_close($ch);
        
        return $return;
    }
 
this return me 
 
Unknown SSL protocol error in connection to api.mercadolibre.com:443 Array
 
searching on google I found the solution, there to add the option  curl_setopt($ch, CURLOPT_SSLVERSION, 3) and it worked. 
 
SOLVED.
 

 

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

for best practises you only add CURLOPT_SSLVERSION => 3 to array $CURL_OPTS like this

 

public static $CURL_OPTS = array(
        CURLOPT_USERAGENT => "MELI-PHP-SDK-1.0.0", 
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_CONNECTTIMEOUT => 10, 
        CURLOPT_RETURNTRANSFER => 1, 
        CURLOPT_TIMEOUT => 60,
        CURLOPT_SSLVERSION => 3
    );

Share this post


Link to post
Share on other sites
  • 0

Fabio,

 

There were 2 days trying to solve this problem! Thank you!

 

Add:

$meli->setSslVersion(3);

Edited by Newerton

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this