简体   繁体   中英

Salesforce API PHP: Generate Token Error SSL23_CLIENT_HELLO

I am referring to API >> http://developer.force.com/cookbook/recipe/interact-with-the-forcecom-rest-api-from-php

I have to generate token to add lead into SF.

Below is my code>> `

if (!isset($code) || $code == "") {
    die("Error - code parameter missing from request!");
}

$params = "code=" . $code. "&grant_type=authorization_code". "&client_id=" . CLIENT_ID. "&client_secret=" . CLIENT_SECRET. "&redirect_uri=" . urlencode(REDIRECT_URI);

$curl = curl_init($token_url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded','Connection: Keep-Alive'));
curl_setopt($curl, CURLOPT_SSLVERSION, 6);

$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
    die("Error: call to token URL $token_url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
}
curl_close($curl);
$response = json_decode($json_response, true);
$access_token = $response['access_token'];
$instance_url = $response['instance_url'];
if (!isset($access_token) || $access_token == "") {
    die("Error - access token missing from response!");
}
if (!isset($instance_url) || $instance_url == "") {
    die("Error - instance URL missing from response!");
}
$_SESSION['access_token'] = $access_token;
$_SESSION['instance_url'] = $instance_url;
`

Above code is working fine on my localhost, but returns below error on server>>

Error: call to token URL https://login.salesforce.com/services/oauth2/token failed with status 0, response , curl_error error:140740BF:SSL routines:SSL23_CLIENT_HELLO:no protocols available, curl_errno 35

We have installed SSL on server. Please advice about issue.

Thanks.

The issue is old OpenSSL library (0.9.8b) that doesn't support TLS 1.2. You need to install OpenSSL 1.0.1 or higher to get TLS 1.1 and TLS 1.2 support.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM