I have a very short code snippet taken directly from mashape:
I've included the paths correctly, as follows:
require_once 'unirest-php-master/src/Unirest.php';
And the code snippet to send a POST request:
$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"
)
);
(I intentionally left the post("url") and the X-Mashape-Key blank since they're private keys.)
I'm not sure why this doesn't work - I tried echoing dummy text in the post method in the corresponding file by adding a method:
public static function echo($a) {
echo $a;
}
in Request.php, but when I tried calling this method with Unirest::echo("abc");
it didn't work either. Is there something wrong with this syntax or is there another problem I'm not seeing?
I'm 100% sure that my file path is right. I feel like I'm missing some obvious fact that I'm not seeing - would appreciate your help on this.
Thanks!
The release of Unirest 2.0 had some breaking changes, mainly the method & class signature has changed. unfortunately the Mashape sample snippets are yet to be updated.
for example: instead of calling Unirest::post
you should be calling Unirest\\Request::post
, please refer to the unirest documentation for more details.
We'll be updating the Mashape samples soon to reflect this change.
I'm the author of unirest-php and I work at Mashape.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.