dongzhao5834 2015-01-02 16:50
浏览 20

PHP包含对TwitterOAuth.php不起作用,但是当我直接复制并粘贴其内容时,一切都很好

I am running into problems trying to include TwitterOAuth.php from https://github.com/abraham/twitteroauth to use the Twitter API.

My problem is this: I have a file called twitter.php in the same directory as my TwitterOAuth.php and OAuth.php files. When I try to use this snippet of code to connect:

include("TwitterOAuth.php");

//I actually fill in these values in my code, no worries...
$apikey = //"...";
$apisecret = //"...";
$accesstoken = //"...";
$accesssecret = //"...";

$connection = new TwitterOAuth($apikey, $apisecret, $accesstoken, $accesssecret);
print_r($connection);

I get this error (line 239 is the $connection=new TwitterOAuth(...) line):

Fatal error: Class 'TwitterOAuth' not found in /home/sites/(mydomain)/public_html/twitteroauth-master/src/twitter.php on line 239

However, if I copy and paste the entire contents of the TwitterOAuth.php file, replacing the line at which I call include("TwitterOAuth.php"); with those contents, everything works fine. I've also tried using include_once, require, and require_once, to no avail.

Please advise - I am very new to PHP and have no idea why copying and pasting works when include() doesn't.

Thanks!

  • 写回答

2条回答 默认 最新

  • dqrnsg6439 2015-01-02 17:02
    关注

    Are your files in the same directory? Since you are using include("TwitterOAuth.php"); then that means the files exist under the same directory. If it were include("../TwitterOAuth.php"); Then the file would exist in the parent directory

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么