Closed SergiTorres closed 7 years ago
can you give me some feedback bro?
Hi,
I'm writing this from memory with a bit of research without actually trying it, so if it doesn't fix it for you, I will go on and dedicate a bit more of my time to reproducing your case.
0) never blindly paste code
1) never paste your actual tokens, secret keys and whatnot
2) var_dump(extension_loaded('curl'));
Does output the line you are referring to. It prints out the value of the function call extension_loaded
. In your case it is true
, so the php-curl
extension is loaded
3) die
stops the script execution dead preventing all remaining commands from executing. That is why there is no further data.
var_dump(extension_loaded('curl')); die;
(we want to see errors while we test things)
ini_set('display_errors', 1);
Have a look at http://stackoverflow.com/a/16495053 and
1) get a hold of certificate authority bundle (CURL provides their bundle here https://curl.haxx.se/ca/cacert.pem) Please don't take my word for it and look up "curl official site", before you download that file
2) save it (as e.g. cacert.pem
) somewhere in your application (the easiest is the same place where the TwitterAPIExchange.php
file is)
3) use the CURLOPT_CAINFO
option to set up the path to the certificate
$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest(true, array('CURLOPT_CAINFO' => "cacert.pem"));
If you are absolutely sure you can trust the certificates, you can set CURL options to ignore the errors. But before you look at the modified code below, please look up the documentation on php.net for: 1) var_dump, 2) die, 3) extension_loaded Then look up 1) CURLOPT_SSL_VERIFYHOST, 2) CURLOPT_SSL_VERIFYPEER
$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest(true, array('CURLOPT_SSL_VERIFYHOST' => 0, 'CURLOPT_SSL_VERIFYPEER' => 0));
Bonus explanation: look at the source code https://github.com/J7mbo/twitter-api-php/blob/master/TwitterAPIExchange.php#L273 where the method you call (performRequest
) accepts array of additional options for CURL as a second argument.
Thank you for helping me. I have tried both cases and are not working.
Actually I'm getting this error:
Argument 2 passed to curl_setopt_array() must be of the type array, integer given, called in C:\wamp64\www\test3\twitter-api-php-master\index.php on line 22 and defined in C:\wamp64\www\test3\twitter-api-php-master\TwitterAPIExchange.php on line 308
I'm not giving the properly variables to curl_setopt_array. I've tried a couple of examples I found on internet but still not working.
I'm uploading my source code to github so you are able to reply the case:
https://github.com/SergiTorres/TwitterTEST/tree/master/twitter-api-php-master
Really thanks dude for trying to help me!
Aha! My bad. I almost had it right.
1) please restore the TwitterAPIExchange.php
to original (remove the modification to curl_setopt_array
)
2) please have a look at my fork https://github.com/kaspiCZ/TwitterTEST/blob/master/twitter-api-php-master/index.php#L23
What I did incorrectly was passing the constants (CURLOPT_CAINFO, CURLOPT_SSL_VERIFYHOST, CURLOPT_SSL_VERIFYPEER
) as strings to the array.
Sorry for the confusion. You can first try with the certificate, or you can comment out the line 23 in my fork if it doesn't work for you and uncomment the line 24
I've tried it out and it worked for me using the cacert.pem, so I'm hoping it will work for you too.
Actually it works! Really thanks for your help dude!
You've been very usefull.
Loves <3!
I am having the same error while retrieving the tweets:
Fatal error: Uncaught exception 'Exception' with message 'SSL certificate problem: unable to get local issuer certificate' in C:\xampp\htdocs\tweets\TwitterAPIExchange.php:315 Stack trace: #0 C:\xampp\htdocs\tweets\index.php(40): TwitterAPIExchange->performRequest() #1 {main} thrown in C:\xampp\htdocs\tweets\TwitterAPIExchange.php on line 315
Can you please guide me as well :( ... I used the same index file which is provided in the project.
Long story short, it should work for you if you:
Make sure your apache has read permissions on the cert file.
Closing as either this issue has been resolved or it's not actually the library. If you still need help feel free to re-open or add another issue with the current state of your problem :)
I have tried to solve the problem with SSL Certificate on line 315. After looking some other people errors I found you told someone to write on the top ----- var_dump(extension_loaded('curl')); die;
After this the SSL error stops appearing but I have another kind of message:
C:\wamp64\www\test3\twitter-api-php-master\index.php:4:boolean true
This is what appears. I think it should appear a list of my followers. My GET request has been pasted from the readme.md file so i guess it should work.
My entire code: