Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3/4 Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(PHP Extension) Simple REST Example (dev.markitondemand.com)Demonstrates a very simple RESTful API call to get a stock quote from Markit On Demand.
<?php // The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number. // For example, if using Chilkat v9.5.0.48, then include as shown here: include("chilkat_9_5_0.php"); // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. $rest = new CkRest(); // Connect to the REST server. $bTls = false; $port = 80; $bAutoReconnect = true; $success = $rest->Connect('dev.markitondemand.com',$port,$bTls,$bAutoReconnect); // Get a stock quote: $success = $rest->AddQueryParam('symbol','AAPL'); $responseXml = $rest->fullRequestNoBody('GET','/MODApis/Api/v2/Quote'); if ($rest->get_LastMethodSuccess() != true) { print $rest->lastErrorText() . "\n"; exit; } // If successful, XML such as shown below is returned. $xml = new CkXml(); $success = $xml->LoadXml($responseXml); // Get the LastPrice print 'LastPrice: ' . $xml->getChildContent('LastPrice') . "\n"; // Show the full XML response, pretty-formatted print $xml->getXml() . "\n"; /* <?xml version="1.0" encoding="utf-8" ?> <StockQuote> <Status>SUCCESS</Status> <Name>Apple Inc</Name> <Symbol>AAPL</Symbol> <LastPrice>94.91</LastPrice> <Change>-2.91</Change> <ChangePercent>-2.9748517686</ChangePercent> <Timestamp>Thu Apr 28 15:17:03 UTC-04:00 2016</Timestamp> <MSDate>42488.6368402778</MSDate> <MarketCap>526236372530</MarketCap> <Volume>4965478</Volume> <ChangeYTD>105.26</ChangeYTD> <ChangePercentYTD>-9.8327949838</ChangePercentYTD> <High>97.88</High> <Low>94.88</Low> <Open>97.61</Open> </StockQuote> */ ?> |
© 2000-2016 Chilkat Software, Inc. All Rights Reserved.