How Do I Write A Simple REST Client in PHP For Fisheye/Crucible REST API
This tutorial teaches you how to interact with Fisheye/Crucible's REST interface from a PHP program. We will be writing the REST Client in PHP using the HTTPFUL Client Library. In this tutorial we will be making a GET Request to the Fisheye/Crucible's REST API to retrieve the server configuration (/rest-service-fecru/server-v1). The tutorial are as follows:-
- Download the HTTPFUL Client Library and place it in the folder where you would be working on.
Create an index.php file and copy the code below in your working folder:
<?php /* * @author Aafrin * @date 22th September 2014 */ //include the HTTPFUL library class include('httpful.phar'); //Make a GET request with BASIC Authentication to retrieve the server configuration $response = \Httpful\Request::get('http://localhost:8060/rest-service-fecru/server-v1') ->authenticateWith('admin', '1234') ->send(); //Display the response echo $response; ?>
- Execute the index.php either from CLI or from browser by executing the php -S localhost:8000 to initiate the PHP built-in web server from the folder you are working on. The execution of the script above will make GET Request to retrieve the server configuration from the Fisheye/Crucible REST API.
最終更新日 2018 年 7 月 31 日
Powered by Confluence and Scroll Viewport.