error setting certificate verify locations: CAfile: D:\wamp\www\public\project\wp-content\themes\digital\cacert.pem CApath: none


#1

Hi

We need to display favorite tweets in website. I was doing earlier by using:

$connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);

$tweets = $connection->get("http://api.twitter.com/1.1/favorites/list.json?count=3&screen_name=".$twitteruser);
 echo json_encode($tweets);

BUT, it suddenly stopped now. So I tried to use CURL as code given below:

 function buildBaseString($baseURI, $method, $params)
{
    $r = array();
    ksort($params);
    foreach($params as $key=>$value){
        $r[] = "$key=" . rawurlencode($value);
    }
    return $method."&" . rawurlencode($baseURI) . '&' . rawurlencode(implode('&', $r));
}

function buildAuthorizationHeader($oauth)
{
    $r = 'Authorization: OAuth ';
    $values = array();
    foreach($oauth as $key=>$value)
        $values[] = "$key=\"" . rawurlencode($value) . "\"";
    $r .= implode(', ', $values);
    return $r;
}

$url = "https://api.twitter.com/1.1/account/totals.json";
//$url ="http://api.twitter.com/1.1/favorites/list.json?count=3&screen_name=harleen88932799";

$oauth_access_token = "1445639443-x8Z1GP76jb5UndMYuVJUlF8aIfvgHQ8UMIrbGdi";
$oauth_access_token_secret = "fp3eXIerHvIIfEVlthQ7PGvNxcDm65XNQxjdlKfGpw5VX";
$consumer_key = "55aAv8xXqzmWyYrfu29Xw";
$consumer_secret = "r3i9v8CkCReR7biUScoNnnjbj7Mh5wlso3m0vu5k8I4";

$oauth = array( 'oauth_consumer_key' => $consumer_key,
                'oauth_nonce' => time(),
                'oauth_signature_method' => 'HMAC-SHA1',
                'oauth_token' => $oauth_access_token,
                'oauth_timestamp' => time(),
                'oauth_version' => '1.0');
				
$base_info = buildBaseString($url, 'POST', $oauth);
$composite_key = rawurlencode($consumer_secret) . '&' . rawurlencode($oauth_access_token_secret);
$oauth_signature = base64_encode(hash_hmac('sha1', $base_info, $composite_key, true));
$oauth['oauth_signature'] = $oauth_signature;

$header = array(buildAuthorizationHeader($oauth), 'Expect:');
$options = array( CURLOPT_HTTPHEADER => $header,
                  CURLOPT_HEADER => false,
                  CURLOPT_URL => $url,
                  CURLOPT_RETURNTRANSFER => true,
                  CURLOPT_SSL_VERIFYPEER => true,
				  CURLOPT_SSL_VERIFYHOST => '2',
				  CURLOPT_CAINFO => "D:\wamp\www\public\digital\wp-content\themes\digital\cacert.pem"
				  );
				  		     
echo get_bloginfo('template_url')."/cacert.pem";
$feed = curl_init();
curl_setopt_array($feed, $options);
$json = curl_exec($feed);
echo curl_error ($feed);
curl_close($feed);

$twitter_data = json_decode($json);
print_r($twitter_data);

I have tried many cert files (like: http://curl.haxx.se/ca/cacert.pem and G3 certificate from VeriSign website. But did not find any solution.
Please guide me how to proceed further? OR is there any other way to show my favorite tweets to website.

Looking forward for quick reply.

Many Thanks