I use VWS - PHP Samples , and it works as expected from the local PC, but when I uploaded it to the server, giving me the following error:
POST 999e93717344885fd7c458301a5b00c9 application / json Thu, 11 Sep 2014 08:14:20 GMT / targetError: OpenSSL support is needed for https: // Requests
https domain name is included with GoDaddy certificate, what is going wrong?
define("SERVER_ACCESS_KEY", "12345678");
define("SERVER_SECRET_KEY", "654321");
define("TARGET_NAME", $campaignname);
define("IMAGE_LOCATION", $directory . '/dispatcher.' . $path_parts['extension']);
$this->load->library('Vuforia/PostNewTarget');
SignatureBuilder.php sample code :
<?php
class SignatureBuilder{
private $contentType = '';
private $hexDigest = 'd41d8cd95fa11b204e7600998ecf8427e';
public function tmsSignature( $request , $secret_key ){
$method = $request->getMethod();
$requestHeaders = $request->getHeaders();
$dateValue = $requestHeaders['date'];
$requestPath = $request->getURL()->getPath();
if( isset( $requestHeaders['content-type'] ))
$this->contentType = $requestHeaders['content-type'];
if ( $method == 'GET' || $method == 'DELETE' ) {
} else if ( $method == 'POST' || $method == 'PUT' ) {
$this->hexDigest = md5( $request->getBody() , false );
} else {
print("ERROR: Invalid content type passed to Sig Builder");
}
$toDigest = $method . "\n" . $this->hexDigest . "\n" . $this->contentType . "\n" . $dateValue . "\n" . $requestPath ;
echo $toDigest;
$shaHashed = "";
try {
$shaHashed = $this->hexToBase64( hash_hmac("sha1", $toDigest , $secret_key) );
} catch ( Exception $e) {
$e->getMessage();
}
return $shaHashed;
}
private function hexToBase64($hex){
$return = "";
foreach(str_split($hex, 2) as $pair){
$return .= chr(hexdec($pair));
}
return base64_encode($return);
}
}
PostNewTarget.php sample code :
<?php
require_once 'HTTP/Request2.php';
require_once 'SignatureBuilder.php';
class PostNewTarget{
private $access_key = SERVER_ACCESS_KEY;
private $secret_key = SERVER_SECRET_KEY;
private $url = "https://vws.vuforia.com";
private $requestPath = "/targets";
private $request;
private $jsonRequestObject;
private $targetName = TARGET_NAME;
private $imageLocation = IMAGE_LOCATION;
function PostNewTarget(){
$this->jsonRequestObject = json_encode( array( 'width'=>320.0 , 'name'=>$this->targetName , 'image'=>$this->getImageAsBase64() , 'application_metadata'=>base64_encode("Vuforia test metadata") , 'active_flag'=>1 ) );
$this->execPostNewTarget();
}
function getImageAsBase64(){
$file = file_get_contents( $this->imageLocation );
if( $file ){
$file = base64_encode( $file );
}
return $file;
}
public function execPostNewTarget(){
$this->request = new HTTP_Request2();
$this->request->setMethod( HTTP_Request2::METHOD_POST );
$this->request->setBody( $this->jsonRequestObject );
$this->request->setConfig(array(
'ssl_verify_peer' => false
));
$this->request->setURL( $this->url . $this->requestPath );
$this->setHeaders();
try {
$response = $this->request->send();
if (200 == $response->getStatus() || 201 == $response->getStatus() ) {
echo $response->getBody();
} else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase(). ' ' . $response->getBody();
}
} catch (HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
private function setHeaders(){
$sb = new SignatureBuilder();
$date = new DateTime("now", new DateTimeZone("GMT"));
$this->request->setHeader('Date', $date->format("D, d M Y H:i:s") . " GMT" );
$this->request->setHeader("Content-Type", "application/json" );
$this->request->setHeader("Authorization" , "VWS " . $this->access_key . ":" . $sb->tmsSignature( $this->request , $this->secret_key ));
}
}


when i try to install openssl
yum install php-openssl openssl
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: centos.mirrors.atwab.net
* extras: centos.mirrors.atwab.net
* updates: centos.mirrors.atwab.net
base | 3.7 kB 00:00
extras | 3.3 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 5.3 MB 00:00
Setting up Install Process
No package php-openssl available.
Package openssl-1.0.1e-16.el6_5.15.x86_64 already installed and latest version
Nothing to do
I tried this code to see openssl available:
if (!extension_loaded('openssl')) {
echo "no openssl extension loaded.";
}
result:
openssl extension not loaded.
it's on CentOS - PHP Version 5.2.17