0

This code is not working:

$ch = curl_init ("https://api.twitter.com/1/statuses/user_timeline/ijustine.json?callback=twitterCallback2&count=4");

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec ($ch);

var_dump($output);

If I try to access: https://api.twitter.com/1/statuses/user_timeline/ijustine.json?callback=twitterCallback2&count=4

From a browser by typing this address manually it works and json is displayed in browser.

But in my script it's not working.

I am using WAMP and curl extension in PHP (5.3.13) is activated because if I run: var_dump( curl_version() ); I get the array where version is 7.25.0.

Btw. this is working: $ch = curl_init ("http://yahoo.com");

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec ($ch);

var_dump($output);

But if I try access http://twitter.com I get string '' (length=0). And if I try https://twitter.com I get boolean false Why?

Do I need to enable any additional php extensions or some apache modules on my localhost or something else?

3

2 Answers 2

3

This is probably a HTTPS certificate issue; check this past question: Can't connect to HTTPS site using cURL. Returns 0 length content instead. What can I do?

Sign up to request clarification or add additional context in comments.

Comments

0

It's very important to note that, very soon, your code will no longer work because you are using the twitter api version 1.0, which is deprecated.

This post explains what's going on in a short version.

Once you've read that, you can head over to this post which explains exactly how to get the tokens you require for the 1.1 api.

Again, your code will very shortly cease to work with Twitter's 1.0 api. Your issue will no longer be that of connecting over HTTPS via cURL - you will get a "not authenticated" error on every request.

So use the above information to start using authenticated requests.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.