0

I'm developing locally on a Windows IIS server and trying to use the Twitter API in my application, like this:

$settings = array(
  'oauth_access_token' => "...",
  'oauth_access_token_secret' => "...",
  'consumer_key' => "...",
  'consumer_secret' => "..."
);

$twitter = new TwitterAPIExchange($settings);

$url = "https://api.twitter.com/1.1/search/tweets.json";
$getfield = "?q=%23test";
$requestMethod = "GET";
$result = $twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest();

echo json_encode($result);

Running this gives me the following error:

Fatal error: Uncaught Exception: SSL certificate problem: unable to get local issuer certificate in C:\inetpub\wwwroot\...\vendor\j7mbo\twitter-api-php\TwitterAPIExchange.php on line 321 Exception: SSL certificate problem: unable to get local issuer certificate in C:\inetpub\wwwroot\...\vendor\j7mbo\twitter-api-php\TwitterAPIExchange.php on line 321

I have found out that you need to add a SSL certificate, I've downloaded the cacert.pem but I'm lost on how to enable it in IIS. Any pointers?

Edit: So I have now imported a certificate from our company in IIS, my server is now running on https. I added this to my php.ini:

curl.cainfo = "C:\...\certificate.PFX"

But after restarting the server I'm still getting the same error.

Besasam
  • 47
  • 1
  • 11
  • https://stackoverflow.com/questions/12916539/simplest-php-example-for-retrieving-user-timeline-with-twitter-api-version-1-1/15314662#15314662 https://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/ – Professor Abronsius Mar 14 '18 at 08:24
  • 3
    Possible duplicate of [PHP - SSL certificate error: unable to get local issuer certificate](https://stackoverflow.com/questions/28858351/php-ssl-certificate-error-unable-to-get-local-issuer-certificate) – Mike Doe Mar 14 '18 at 08:26

1 Answers1

0

Okay, turns out all that hassle of installing our company's certificate was unneeded. I followed these instructions (thanks RamRaider) and it works. Hurrah \o/

Besasam
  • 47
  • 1
  • 11