我有一个非常短的代码片段,直接取自 mashape:
我已正确包含路径,如下所示:
require_once 'unirest-php-master/src/Unirest.php';
以及发送 POST 请求的代码片段:
$response = Unirest::post("",
array(
"X-Mashape-Key" => "",
"Content-Type" => "application/x-www-form-urlencoded",
"Accept" => "application/json"
),
array(
"selector" => "FACE, EYES, FULL",
"url" => "http://api.animetrics.com/img/test/sc.jpg"
)
);
(我故意将 post("url") 和 X-Mashape-Key 留空,因为它们是私钥。)
我不确定为什么这不起作用 - 我尝试通过添加一个方法在相应文件的 post 方法中回显虚拟文本:
public static function echo($a) {
echo $a;
}
在 Request.php 中,但是当我尝试使用它调用此方法时,Unirest::echo("abc");
它也不起作用。这种语法有问题还是我没有看到另一个问题?
我 100% 确定我的文件路径是正确的。我觉得我错过了一些我没有看到的明显事实 - 感谢您在这方面的帮助。
谢谢!