2017 © Pedro Peláez
 

library gsm-api

GlobalSportsMedia (GSM) API client

image

kbsali/gsm-api

GlobalSportsMedia (GSM) API client

  • Friday, February 28, 2014
  • by kbsali
  • Repository
  • 1 Watchers
  • 5 Stars
  • 623 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

PHP GSM API

A simple PHP5 Object Oriented wrapper for GlobalSportsMedia (GSM) XML API., (*1)

See http://client.globalsportsmedia.com/documentation, (*2)

Features

  • Follows PSR-0 conventions and coding standard: autoload friendly
  • API entry points implementation state :
    • OK soccer
    • OK am_football
    • OK aus_football
    • OK baseball
    • OK basketball
    • OK cricket
    • OK golf
    • OK handball
    • OK hockey
    • OK motorsports
    • OK rugby
    • OK tennis
    • OK volleyball

Requirements

  • PHP >= 5.4 with cURL extension,

Install

Through composer, simply run :, (*3)

$ php composer.phar require kbsali/gsm-api:1.*

Basic usage of php-gsm-api client

All the methods return a SimpleXmlElement object or throw an Exception in case of error. Following the basic workflow documented in globalsportsmedia.com for working with Soccer data :, (*4)

<?php

// This file is generated by Composer
require_once 'vendor/autoload.php';

$client = new GlobalSportsMedia\Client('http://webpull.globalsportsmedia.com', 'USERNAME', 'PASSWORD');
$client
    ->cacheOn() // for live method (like get_matches_live_updates) you might want to disable caching
    ->setCacheDir(__DIR__.'/cache') // path where xml responess will be cached
;

try {
    $seasons = $client->api('soccer')->get_seasons(['authorized' => 'yes']);
    foreach ($seasons->competition as $competition) {
        foreach ($competition->season as $season) {
            $matches = $client->api('soccer')
                ->cacheOncePerDay() // cache, but only once a day!
                ->get_matches(
                    (int) $season['season_id'],
                    'season',
                    ['detailed' => 'yes', 'start_date' => date('Y-m-d H:00:00')]
                )
            ;
            // process matches...
        }
    }
} catch(\Exception $e) {
    die($e->getMessage());
}

You can control if you want to cache the requests to the API (get_seasons() is not likely to change everyday):, (*5)

  • cacheOff() to never cache the request
  • cacheOn() to cache the request undefinitely (ie. until to clean the cache)
  • cacheOncePerDay() to cache requests for the current day

If you wish to cache the requests you will have to specifiy the cache directory through setCacheDir(), (*6)

The Versions

28/02 2014

dev-master

9999999-dev https://github.com/kbsali/php-gsm-api

GlobalSportsMedia (GSM) API client

  Sources   Download

MIT

The Requires

  • php >=5.4
  • ext-curl *

 

api xml gsm sport globalsportsmedia

17/02 2014

1.0.3

1.0.3.0 https://github.com/kbsali/php-gsm-api

GlobalSportsMedia (GSM) API client

  Sources   Download

MIT

The Requires

  • php >=5.4
  • ext-curl *

 

api xml gsm sport globalsportsmedia

23/12 2013

1.0.2

1.0.2.0 https://github.com/kbsali/php-gsm-api

GlobalSportsMedia (GSM) API client

  Sources   Download

MIT

The Requires

  • php >=5.4
  • ext-curl *

 

api xml gsm sport globalsportsmedia

13/12 2013

1.0.0

1.0.0.0 https://github.com/kbsali/php-gsm-api

GlobalSportsMedia (GSM) API client

  Sources   Download

MIT

The Requires

  • php >=5.4
  • ext-curl *

 

api xml gsm sport globalsportsmedia