0

I'm a complete PHP/wamp noob but am just trying to get a simple bit of code to work. I'm using a library to help me out with OAuth for Twitter, and have been writing and testing my code with wamp on Windows.

This is my code:

<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>

And the error message I get: Fatal error: Call to undefined function curl_init() in C:\wamp\www\PHP\tmhOAuth.php on line 581 tmhOAuth is one of the library files I'm using.

After a quick Google, I followed this tutorial: http://www.phpmind.com/blog/2011/02/how-to-enable-curl-in-wamp/ I found php.ini in both the apache and php folders, and uncommented the lines about curl. I also replaced php_curl.dll in the ext folder with a different version of the file as instructed by another tutorial I found.

Please help

4

2 回答 2

1

您是否检查了哪个 php.ini 与您的 PHP 一起加载?制作 php 文件并将 phpinfo() 放入其中,运行它并检查“加载的配置文件”

您是否重新启动了网络服务器?因为 php.ini 在您的情况下会在网络服务器重新启动时重新加载。

这个类使用https协议吗?然后您还需要取消注释 openssl 扩展。

于 2012-10-25T18:55:23.383 回答
0

在 Windows中测试配置的一个好PHP.INI方法是运行 PHP-CLI 或检查日志。

您可以打开cmd并运行命令php以查看您的 conf 发生了什么。

于 2012-10-25T18:52:32.637 回答