本文介绍了CakePHP与Twitter时间轴,使用twitteroauth,得到curl_init()错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

确定,在我开始之前,我在一个虚拟的盒子运行Ubuntu的确实有CURL安装和工作!

ok, before I start I am building this in a virtual box running with Ubuntu which does have CURL installed and working!

这样阅读一些博客文章和帮助网站,我使用以下代码从twitter构建我的时间轴,

So reading a number of blog posts and help sites, I used the following code to build pull in my timeline from twitter,

    require_once("twitteroauth.php");

    $twitteruser = "MY-TWITTER-NAME";
    $notweets = 30;
    $consumerkey = "XXXX-XXXXXXX";
    $consumersecret = "XXXX-XXXXXXX";
    $accesstoken = "XXXX-XXXXXXX-XXXX-XXXXXXX";
    $accesstokensecret = "XXXX-XXXXXXXXXXX-XXXXXXXXXXX-XXXXXXX";

    function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) {
      $connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
      return $connection;
    }

    $connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);

    $GetAllMyTweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser."&count=".$notweets);

这一切正常,没有问题,问题是当我尝试在我的CakePHP网站使用它,我有以下代码使用形式的博客我找到,

This all works, no problems, the problem is when I try to use it within my CakePHP site, I have the current following code used form a blog I found,

        App::import('Vendor', 'twitteroauth', array('file' => 'twitteroauth'. DS .'twitteroauth.php')); <- outside the controller call

public function Index(){

public function Index() {

    $consumerkey = "XXXX-XXXXXXX";
    $consumersecret = "XXXX-XXXXXXX";
    $accesstoken = "XXXX-XXXXXXX-XXXX-XXXXXXX";
    $accesstokensecret = "XXXX-XXXXXXXXXXX-XXXXXXXXXXX-XXXXXXX";



    $Oauth = new TwitterOAuth ($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);

    $Credentials = $Oauth->get("account / verify_credentials ");

    debug($Credentials);
    die();

    //$this->render('/Pages/Main');
}

但我得到以下错误:

               Error: Call to undefined function curl_init()    
               File: /var/www/app/Vendor/twitteroauth/twitteroauth.php  
               Line: 199

我不明白?我做错了什么?或者我不在做什么?

Which I don't understand? What I am doing wrong? Or what I am not doing? Or do I have to pull in a helper or something to let CakePHP work with the CURL?

请帮助

Glenn。

推荐答案

安装curl并安装php5-curl扩展是两个不同的事情。

Having Curl installed and having php5-curl extension installed are two different things.

这篇关于CakePHP与Twitter时间轴,使用twitteroauth,得到curl_init()错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 06:25