Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error with PHP 5.3 #175

Closed
zuk22 opened this issue Mar 29, 2014 · 6 comments
Closed

error with PHP 5.3 #175

zuk22 opened this issue Mar 29, 2014 · 6 comments
Assignees
Labels

Comments

@zuk22
Copy link

zuk22 commented Mar 29, 2014

Hi.
When I change version of PHP from 5.2 to 5.3 the code below show an error - Warning: Invalid argument supplied for foreach()
On PHP 5.2 it's working good.

$tmhOAuth = new tmhOAuth(array(
'consumer_key' => '_',
'consumer_secret' => '_
_',
'user_token' => '
__',
'user_secret' => '_
****',
'curl_ssl_verifypeer' => FALSE
));
$code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array(
'screen_name' => $twitter_username,
'count' => $tweets_count
));
$response = $tmhOAuth->response['response'];
$tweets = json_decode($response);
foreach($tweets as $tweet){
$twit_text = $tweet->text;
}

@themattharris
Copy link
Owner

i haven't tested the code but on inspection this looks like it might be because $tweets isn't an array but instead is NULL because the json_decode failed.

can you validate that $code == '200' before attempting to decode the response?

@zuk22
Copy link
Author

zuk22 commented Jul 7, 2014

Hi. Thank's for answering me.
I tested the code and get error = '0'.
It's occur when I change PHP version from 5.2 to 5.3 on my host

@themattharris
Copy link
Owner

that error usually means curl cannot open a connection to the remote server. in the past others have reported this happens when OpenSSL isn't correctly configured for your compiled PHP.

what does $tmhOAuth->response['error'] contain?

@randallflagg34
Copy link

Hey, I'm having this same issue.
I'm on Hostgator running PHP 5.4 (I'm trying to switch to 5.2 but I need support from them to do that).

My error is:
["error"]=>
string(24) "couldn't connect to host"
["errno"]=>
int(7)

As far as I know my cacert.pem is being loaded, the DIR is working nice.
Most likelly is the PHP version, right?

@themattharris
Copy link
Owner

no, that error means curl cannot connect to the host specified (which defaults to api.twitter.com).

what does php -i | grep OpenSSL give you?
and can you ping api.twitter.com?

@randallflagg34
Copy link

Yes, I tried and indeed it was a problem from hostgator, it gave me Time Out. The same thing I tried from bluehost and had no problem.
I talked to the support team and they where kind enough to look into the issue and try to resolve stuffs, which they did. Just to have it in mind: it can be your hosting provider blocking something without noticing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants