Skip to content

Instantly share code, notes, and snippets.

@themattharris
Last active December 21, 2015 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themattharris/6273201 to your computer and use it in GitHub Desktop.
Save themattharris/6273201 to your computer and use it in GitHub Desktop.
verify_ssl for v1.1. this requires a valid oauth_token and secret
<?php
$tmhOAuth = new tmhOAuth(array(
'curl_ssl_verifypeer' => true,
'curl_ssl_verifyhost' => 2,
'consumer_key' => 'YOUR_CONSUMER_KEY',
'consumer_secret' => 'YOUR_CONSUMER_SECRET',
'user_token' => 'A_USER_TOKEN',
'user_secret' => 'A_USER_SECRET',
));
// Make an SSL request to the Twitter API
$code = $tmhOAuth->user_request(array(
'url' => $tmhOAuth->url('1.1/account/verify_credentials')
));
// Verify the SSL worked as expected
if ($code == 200 && $tmhOAuth->response['info']['ssl_verify_result'] === 0) {
echo 'A verified SSL connection was successfully made to ' . $tmhOAuth->response['info']['url'] . PHP_EOL;
} elseif ($code == 200 && $tmhOAuth->response['info']['ssl_verify_result'] !== 0) {
echo 'ERROR: A verified SSL connection could not be successfully made to ' . $tmhOAuth->response['info']['url'] . PHP_EOL;
echo 'The error was: ' . $tmhOAuth->response['error'];
} elseif ($code !== 200) {
echo 'ERROR: There was a problem making the request' . PHP_EOL;
if (!empty($tmhOAuth->response['error']))
echo 'The error was: ' . $tmhOAuth->response['error'] . PHP_EOL;
else
echo 'The HTTP response code was: ' . $code . PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment