Twitter OAUTH - returns the response code "0"

I tried using the Matt Harris OAUTH Twitter library (https://github.com/themattharris/tmhOAuth), replacing the default data with my keys and tokens, but for some reason I cannot get a valid response code.

The url I'm testing ends with the port (8888), but I'm not sure if this is related to it. I am closing the PHP log and there are no errors.

$tweet_text = 'Hello world!';
print "Posting...\n";
$result = post_tweet($tweet_text);
print "Response code: " . $result . "\n";

function post_tweet($tweet_text) {

  require_once('tmhOAuth.php');

  $connection = new tmhOAuth(array(
    'consumer_key'    => '(hidden)',
    'consumer_secret' => '(hidden)',
    'user_token'      => '(hidden)',
    'user_secret'     => '(hidden)',
  )); 

  $connection->request('POST', 
    $connection->url('1/statuses/update'), 
    array('status' => $tweet_text));

  return $connection->response['code'];
}

Does anyone have any ideas?

Many thanks.

+5
source share
3 answers

I had this problem and due to this recent change in December 2011:

"By default, CURLOPT_SSL_VERIFYPEER is true"

If you upload the answer $ connection->, as Darren advises, you can see an error like me:

string (165) " :

, cacert.pem , SSL_VERIFYPEER.

, ( ):

$connection = new tmhOAuth(array(
    'consumer_key'          => '(hidden)',
    'consumer_secret'       => '(hidden)',
    'user_token'            => '(hidden)',
    'user_secret'           => '(hidden)',
    'curl_ssl_verifypeer'   => false
));

2015

, , curl_ssl_verifypeer false - ( , Twitter, ). , , , Root CA Certificate (cacert.pem) .

+14

https://github.com/themattharris/tmhOAuth/blob/master/examples/tweet.php, :

$code=$connection->request('POST', ...);
return $code;

, , . , $this->response['code'] , . -, ( curlit()) void. response['code'], undefined. ( , .)

, void, $this->config['prevent_request'] . , , , .

, error_reporting(E_ALL|E_NOTICE) , . print_r($connection->response) request(), , .

+1

, , .

TMH git repo:

0.60 curl_ssl_verifypeer true. - , TMH. , : http://curl.haxx.se/ca/cacert.pem

tmhOAuth , SSL , /verify _ssl.php script.

+1

All Articles