Hello folks, hope you are doing good. In one of my recent project, I get a chance to create RESTClient a debugger for RESTful web services using PHP.
In today’s tutorial, I will share very useful things with you. After this tutorial, you will able to create a restCliient using PHP.
In order to create RestClient using PHP, first you have to include the
httpful.phar file to perform the request and receive Http requests. Download the complete code from the link included at the end of this tutorial. Create a
index.php page and copy paste below code:
* Created by Prem Tiwari.
* User: prem.tiwari
* Date: 2/16/2017
* Time: 4:08 PM
// Point to the httpful.phar file path
//set header content type as json
$uri = "http://localhost:3000/api/v1/tokenize";
$header['merchantID'] = "test";
$header['Content-Type'] = "application/json";
//set the request data
$body['cardNumber'] = "xxxxxxxxxxxx1111";
$body['securityCode'] = "xxx";
$body['cardIssuer'] = "Prem Tiwari";
$body['expirationDate'] = "11/2020";
$response = \Httpful\Request::post($uri)
$res['success'] = $response->body->success;
$res['token'] = $response->body->token;
If you still need any help to create RestClient, then feel free to add your comments in below comment section. Do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool tutorials.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: best php tutorials, json and php tutorial, php beginners, php rest api client, php rest client, php rest client example, php tutorials for beginners, rest client php, rest client php example, RestClient using php