Php Client

This sample shows how to instantiate a simple client class to access our basic feed services.

View the classes here:

<?
/**
 * Sample client for Don Best Sports Web Services API
 * Don Best Sports 2010
 *
 * PHP 5.*
 * Requires php-soap
 * LICENSE: This work is licensed under a Creative Commons Attribution 3.0 Unported License
 * http://creativecommons.org/licenses/by/3.0/
 * 
 * @category   Public Samples
 * @package    php web services client
 * @author     Matthew Belzberg <mbelzberg@donbest.com>
 */
 
// set base file path to the directory containing the class files
define('APP',"/var/www/html/");
/* save the class files in a classes folder or update the paths below */
$username = "username"
$password = "password"
 
/* Specify the kind of data you want to access */
/* Possible Parameters */
// schedule
// scores
// injuries
/* lines */
// currentLines
// opeingLines
// openingPrev
// closing
$type = 'schedule';
 
/* access values as class properties ie. $result->value
see http://ca.php.net/manual/en/book.soap.php */
 
switch ($type) {
 
    case 'schedule':
        /* schedule*/
        include(APP."/classes/schedule_auth.php");
        $today = date('Y-m-d')."T".date('H:i:s')."Z";
        $events = new ScheduleService();
        $params = new ScheduleType();
        $params->date = $today;
        $result = $events->Schedule($params,$username,$password);
        if (is_soap_fault($result)) {
            trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
        }
        else{
            print_r($result);
        }
 
    break; 
 
    case 'scores':
        /* scores*/
        include(APP."/classes/ScoresService.php");
        $today = date('Y-m-d')."T".date('H:i:s')."Z";
        $scores = new ScoresService();
        $params = new ScoresRequest();
        $params->date = $today;
        $result = $scores->Scores($params,$username,$password);
        if (is_soap_fault($result)) {
            trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
        }
    break;  
 
    case 'injuries':
        /* injuries*/
        include(APP."/classes/InjuriesService.php");
        $today = date('Y-m-d')."T".date('H:i:s')."Z";
        $injuries = new InjuriesService();
        $params = new InjuriesRequest();
        $params->date = $today;
        $result = $injuries->Injuries($params,$username,$password);
        if (is_soap_fault($result)) {
            trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
        }
    break;
 
    case 'currentLines':
 
    // current lines
    include(APP."/classes/LinesService.php");
    $today = date('Y-m-d')."T".date('H:i:s')."Z";
    $lines= new LinesService();
    $params = new LinesRequestType();
    $params->TimeStamp = $today;
    $result = $lines->CurrentLines($params,$username,$password);
    if (is_soap_fault($result)) {
        trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
    }
    break;
 
    case 'opeingLines':
        // opening lines
        include(APP."/classes/LinesService.php");
        $today = date('Y-m-d')."T".date('H:i:s')."Z";
        $lines= new LinesService();
        $params = new LinesRequestType();
        $params->TimeStamp = $today;
        $result = $lines->OpeningLines($params,$username,$password);
        if (is_soap_fault($result)) {
            trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
        }
    break;
 
    case 'openingPrev':
 
        //CurrentAndPreviousLines
        include(APP."/classes/LinesService.php");
        $today = date('Y-m-d')."T".date('H:i:s')."Z";
        $lines= new LinesService();
        $params = new LinesRequestType();
        $params->TimeStamp = $today;
        $result = $lines->CurrentAndPreviousLines($params,$username,$password);
        if (is_soap_fault($result)) {
            trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
        }
    break;
 
    case 'closing':
    //Closing
        include(APP."/classes/LinesService.php");
        $today = date('Y-m-d')."T".date('H:i:s')."Z";
        $lines= new LinesService();
        $params = new LinesRequestType();
        $params->TimeStamp = $today;
        $result = $lines->ClosingLines($params,$username,$password);
        if (is_soap_fault($result)) {
            trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
        }
    break;
 
}
 
?>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License