mashape api Class 'Unirest' not found error in php code -


i download php source code mashape api https://github.com/composer/composer url install composer git command $ curl -ss https://getcomposer.org/installer | php

i include

{   "require" : {     "mashape/unirest-php" : "dev-master"   },   "autoload": {     "psr-0": {"unirest": "lib/"}   } } 

this line of code in composer.json , create new file test.php name on root directory , include

require_once '/test/unirest.php'; $response = unirest::post("http://httpbin.org/post", array( "accept" => "application/json" ),   array(     "parameter" => 23,     "foo" => "bar"   ) );  $response->code; // http status code $response->headers; // headers $response->body; // parsed body $response->raw_body; // unparsed body 

after above process run php source code display class "unirest" not found there way solve this?

hey using unirest, it's great tool developers, use unirest daily can ya out:

first of didn't include/require library composer need require autoload.php in vendor folder generated composer itself

secondly you're being returned array example display raw_body gotta use print_r();

hope helps, best! mashape sheriff :d

working + related code:

<?php require 'vendor/autoload.php'; $response = unirest::post("http://httpbin.org/post", array( "accept" => "application/json" ), array(    "parameter" => 23,    "foo" => "bar"   ) ); print_r($response->raw_body); ?> 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -