twitter-api-php icon indicating copy to clipboard operation
twitter-api-php copied to clipboard

Unknown SSL protocol error in connection to api.twitter.com:443

Open frtlec opened this issue 3 years ago • 0 comments

`<?php
	// include config and twitter api wrappe
	require_once( 'config.php' );
	require_once( './twitter-api-php-master/TwitterAPIExchange.php' );

	// settings for twitter api connection
	$settings = array(
		'oauth_access_token' => TWITTER_ACCESS_TOKEN, 
		'oauth_access_token_secret' => TWITTER_ACCESS_TOKEN_SECRET, 
		'consumer_key' => TWITTER_CONSUMER_KEY, 
		'consumer_secret' => TWITTER_CONSUMER_SECRET
	);

	// twitter api endpoint
	$url = 'https://api.twitter.com/1.1/statuses/update.json';
	
	// twitter api endpoint request type
	$requestMethod = 'POST';

	// twitter api endpoint data
	$apiData = array(
	    'status' => 'This tweet is comming from an awesome script written using php and the Twitter API! #Geek #PHP #TwitterAPI',
	);

	// create new twitter for api communication
	$twitter = new TwitterAPIExchange( $settings );

	// make our api call to twiiter
	$twitter->buildOauth( $url, $requestMethod );
	$twitter->setPostfields( $apiData );
	$response = $twitter->performRequest( true, array( CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_SSL_VERIFYPEER => 0 ) );

	// display response from twitter
    echo '<pre>';
    print_r( json_decode( $response, true ) );
?>`

I am using wamp server 2.2. What could be the cause of this error?

PHP Version 5.3.10 APACHE 2.2

frtlec avatar Sep 07 '20 13:09 frtlec