繁体   English   中英

尝试访问 Factual API 时出现 PHP 错误

[英]PHP error when trying to access Factual API

我正在将 WAMP 用于我的 PHP 框架。 我正在尝试测试此代码

<?php
require_once "C:\wamp\www\factual-php-driver-master\Factual.php";
$factual= new Factual("/*API Key*/","/*API Secret*/");

$query= new FactualQuery;
$query->limit(3);
$res= $factual->fetch("places", $query);
print_r($res->getData());
?>

我的 Factual.php 文件的 PATH 绝对正确,但该文件返回以下错误

警告:require_once(C:\\wamp\\wwwactual-php-driver-master\\Factual.php):无法打开流:第 2 行 C:\\wamp\\www\\foodmeets\\restaurants.php 中的参数无效

致命错误:require_once():在 C:\\wamp\\www\\ 中打开所需的 'C:\\wamp\\wwwactual-php-driver-master\\Factual.php' (include_path='.;C:\\php\\pear') 失败第 2 行的 foodmeets\\restaurants.php

请注意,我已经使用以下命令对 PHP 安装环境进行了测试

php -f test.php yourFactualKey yourFactualSecret [logfile]

如 Github 上 PHP 的 Factual Driver(V3) 中所述( https://github.com/Factual/factual-php-driver

您必须转义 \\f (\\f 元字符用于查找换页符。)

require_once "C:\wamp\www\\factual-php-driver-master\Factual.php";

PHP 将您的反斜杠转换为特殊字符。 例如, ... arrays\\news.php变成了

...数组

ews.php

你应该像这样逃避他们:

$path = "C:\\NucServ\\www\\vv\\static\\arrays\\news.php"; 或者使用单打,像这样:

$path = 'C:\\NucServ\\www\\vv\\static\\arrays\\news.php';

另外,你的 if 搞砸了。 您不应再次打开该文件。 只需使用您已有的 $fp 即可。

无法打开流:无效参数

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM