尝试访问API时出现PHP错误

尝试访问API时出现PHP错误,php,factual,Php,Factual,我正在为我的PHP框架使用WAMP。我正在尝试测试这段代码 <?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)

我正在为我的PHP框架使用WAMP。我正在尝试测试这段代码

<?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());
?>
正如Github()上PHP的实际驱动程序(V3)中所述,

必须转义\f(元字符用于查找表单提要字符)


您的反斜杠由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


Source

是的,它现在正在工作,但您能解释为什么会发生这种情况吗?实际上,C:\wamp\www\factual php driver master\factual.php,在这个\factual php driver master中有一个\f元字符,用于查找表单提要字符。在php中,我们需要使用额外的反斜杠来逃避所有这些事情,因此需要使用php驱动程序master。
php -f test.php yourFactualKey yourFactualSecret [logfile]
require_once "C:\wamp\www\\factual-php-driver-master\Factual.php";