Twitter-API-PHP only return NULL


#1

Hi,
I’m making a code to take users using Twitter-API-PHP, but the return is always NULL.

Below is my code:

<?php

//Include the class file
require_once(‘TwitterAPIExchange.php’);

//Set access tokens
$settings = array(
‘oauth_access_token’ => “214180610-XXXXX”,
‘oauth_access_token_secret’ => “XXXXX”,
‘consumer_key’ => “XXXX”,
‘consumer_secret’ => “XXXXX”
);

//GET Request Example

$url = ‘https://api.twitter.com/1.1/users/search.json’;
$getfield = ‘?q=Danilo&page=1&count=1’;
$requestMethod = ‘GET’;

$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();

var_dump(json_decode($response));

?>


________________________________________

Are there something wrong? I tried put the codes examples, but all only return NULL.
What should I do?


Thanks.

#2

are you entering your full tokens or have you just xxxxx them out for the example ?


#3

hey @MrDnlGomes did you finally manage to make the code work? I’m getting a NULL as well and can’t figure exactly what’s wrong since it doesn’t say that much, just NULL.


#4

I have the same problem as you! Same code (except that I retrieve the last tweet of an user) and same problem.
It would be great if someone could help us…


#5

Good morning

I’ve solved this by editing TwitterAPIExchange.php file.
Just adding

CURLOPT_SSL_VERIFYPEER => false

at the $options array at the performRequest method (line 180 in my case)

cheers


#6

Thanks a lot @JuanDiegoMu_oz, this solved it!


#7

+1


#8

A+++++++++++ works thanks yaar