Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何让Twitter PHP类处理IIS8(卷曲问题?)_Php_Curl_Twitter_Iis 8 - Fatal编程技术网

如何让Twitter PHP类处理IIS8(卷曲问题?)

如何让Twitter PHP类处理IIS8(卷曲问题?),php,curl,twitter,iis-8,Php,Curl,Twitter,Iis 8,我决定把我的网站和我的twitter账户结合起来。为了正确使用它,我想发布一条推特。我决定从这里开始使用非常简单的类TwitterAPIExchange: 我在我的Linux服务器上测试了它,一切正常。但是我想在我的Windows服务器上使用这个工具。这是我的设置:Windows 2012、IIS 8、PHP 这是我的测试代码 // Setup $settings = array( ... ); $url = 'https://api.twitter.com/1.1/statuses/updat

我决定把我的网站和我的twitter账户结合起来。为了正确使用它,我想发布一条推特。我决定从这里开始使用非常简单的类TwitterAPIExchange:

我在我的Linux服务器上测试了它,一切正常。但是我想在我的Windows服务器上使用这个工具。这是我的设置:Windows 2012、IIS 8、PHP

这是我的测试代码

// Setup
$settings = array( ... );
$url = 'https://api.twitter.com/1.1/statuses/update.json';

// Post the data
$requestMethod = 'POST';

$postfields = array('status' => 'Hello World');

$twitter = new TwitterAPIExchange($settings);
$json = $twitter->buildOauth($url, $requestMethod)->setPostfields($postfields)->performRequest();

var_dump($json);
在windows计算机上,它返回

bool(false)

一直都是!这是什么意思?这是curl和IIS的问题吗?我在网上读了几篇关于它的文章,但至今没有一篇对我有帮助。非常感谢您的任何意见

Curl给了我以下错误:

curl iis SSL certificate problem, verify that the CA cert is OK
由于我无法在IIS上使用证书,因此我遵循了论坛()上给出的提示,该提示告诉我添加以下curl选项:

curl_setopt( $ch , CURLOPT_SSL_VERIFYPEER , false );
curl_setopt( $ch , CURLOPT_SSL_VERIFYHOST , false ); 

最后,我将它添加到使用curl的TwitterAPIExchange类中。

您可能需要下载一个证书包并将脚本指向它。以下方面应起作用:

  • 将此文件保存到与PHP文件相同的目录:
  • CURLOPT\u CAINFO=>'cacert.pem'
    添加到选项部分,该部分从当前版本代码的第192行开始:

  • 您还可以使用另一个有效的证书捆绑包并将其保存到其他地方,只要在代码中包含指向它的路径。

    您是否正确配置并启用了curl扩展?我不确定,我只是通过IIS安装了PHP(安装程序)。当我使用phpinfo()时;它说:“cURL支持:enabled”。但我还是觉得有点不对劲?如果curl配置正确,有没有简单的方法?