J7mbo / twitter-api-php

The simplest PHP Wrapper for Twitter API v1.1 calls
MIT License
1.82k stars 800 forks source link

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

Open frtlec opened 4 years ago

frtlec commented 4 years ago
`<?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