J7mbo / twitter-api-php

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

Response null after search hashtag in Russian #136

Closed babymaster closed 9 years ago

babymaster commented 9 years ago

Hi guys,

require THEME_DIR . 'inc/TwitterAPIExchange.php';
$settings = array(
    'oauth_access_token'        => $t_access_token,
    'oauth_access_token_secret' => $t_token_secret,
    'consumer_key'              => $t_cosumer_key,
    'consumer_secret'           => $t_cosumer_secret ,
);
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$fields = "?q=%23цветы&result_type=recent&count=100&include_entities=true";
$method = 'GET';
    $twitter = new TwitterAPIExchange( $settings );
    $tweets = $twitter->setGetfield( $fields )->buildOauth( $url, $method )->performRequest();
    $tweets = json_decode( $tweets );

It returned: NULL after executed and when I display on DEBUG so get the result is:

array(5) {
  ["headers"]=>
  array(11) {
    ["content-encoding"]=>
    string(7) "deflate"
    ["content-length"]=>
    string(4) "1439"
    ["content-security-policy"]=>
    string(524) "default-src 'none'; img-src https://abs.twimg.com https://ssl.google-analytics.com http://www.google-analytics.com; script-src https://abs.twimg.com https://ssl.google-analytics.com https://ajax.googleapis.com http://www.google-analytics.com about:; style-src https://abs.twimg.com https://fonts.googleapis.com 'unsafe-inline'; font-src https://abs.twimg.com https://twitter.com; connect-src 'none'; object-src 'none'; media-src 'none'; frame-src 'none'; report-uri https://twitter.com/i/csp_report?a=ORTGK%3D%3D%3D&ro=false"
    ["content-type"]=>
    string(23) "text/html;charset=utf-8"
    ["date"]=>
    string(29) "Mon, 20 Jul 2015 15:11:46 GMT"
    ["server"]=>
    string(5) "tsa_k"
    ["set-cookie"]=>
    string(100) "guest_id=v1%3A143740510592053897; Domain=.twitter.com; Path=/; Expires=Wed, 19-Jul-2017 15:11:45 UTC"

    ["strict-transport-security"]=>
    string(17) "max-age=631138519"
    ["x-connection-hash"]=>
    string(32) "ab883c5bb1cdafd85da3303c5729790a"
    ["x-response-time"]=>
    string(3) "209"
    ["x-xss-protection"]=>
    string(13) "1; mode=block"
  }
  ["body"]=>
  string(4458) "'
babymaster commented 9 years ago

I solved the problem follow a topic in here. Just need to add the second parameter of method performRequest is: array( CURLOPT_SSL_VERIFYPEER => false). Thanks

J7mbo commented 9 years ago

Thought it might have been an encoding issue, but glad it' sorted now :-)