【发布时间】:2012-10-16 00:40:30
【问题描述】:
我是一个完整的 PHP/wamp 菜鸟,但我只是想让一些简单的代码工作。我正在使用一个库来帮助我使用 OAuth for Twitter,并且一直在 Windows 上使用 wamp 编写和测试我的代码。
这是我的代码:
<html>
<body>
<?php
include 'tmhOAuth.php';
include 'tmhUtilities.php';
$tweet_text = 'Test Tweet. If you can see this, my PHP code is working! Yay';
echo "Posting...\n";
$result = post_tweet($tweet_text);
echo "Response code: " . $result . "\n";
function post_tweet($tweet_text) {
$connection = new tmhOAuth(array(
'consumer_key' => 'xxxxxxxxxx',
'consumer_secret' => 'xxxxxxxxxxxx',
'user_token' => 'xxxxxxxxxxxxxxxxx',
'user_secret' => 'xxxxxxxxxxxxxx',
));
$connection->request('POST',
$connection->url('1/statuses/update'),
array('status' => $tweet_text));
return $connection->response['code'];
}
?>
</body>
</html>
我得到的错误信息是: 致命错误:在第 581 行调用 C:\wamp\www\PHP\tmhOAuth.php 中未定义的函数 curl_init() tmhOAuth 是我正在使用的库文件之一。
在快速谷歌之后,我遵循了这个教程: http://www.phpmind.com/blog/2011/02/how-to-enable-curl-in-wamp/ 我在 apache 和 php 文件夹中都找到了 php.ini,并取消了有关 curl 的注释。我还按照我找到的另一个教程的指示,用不同版本的文件替换了 ext 文件夹中的 php_curl.dll。
请帮忙
【问题讨论】:
-
重新检查所有内容:您的 PHP 扩展路径是否正确定义?您是否尝试重新启动 WAMP?您是否尝试过此处描述的步骤:technoreaders.com/2009/07/26/curl-on-wamp?
-
你能在你的网络服务器中创建一个文件来显示phpinfo吗?
<?php phpinfo(); ?>。搜索 curl 以查看它是否存在并在您的 phpinfo 显示中启用。如果不是,则 curl 模块未启用 -
似乎没有正确安装 cURL 扩展。您可以通过 phpinfo() 验证安装是否正确
-
我在 php 信息文件中找不到 curl 所以猜测它没有启用...