Skip to content

Instantly share code, notes, and snippets.

@mach3
Created October 17, 2011 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mach3/1292371 to your computer and use it in GitHub Desktop.
Save mach3/1292371 to your computer and use it in GitHub Desktop.
Servces_Twitterを拡張して定義ファイルを追加で読み込めるようにする。
<?php
$foo = new MY_Services_twitter();
$foo->addAPI( "/the/path/to/your/api.xml" );
<?php
require_once( "Services/Twitter.php" );
class MY_Services_twitter extends Services_twitter {
public function __construct(){
parent::__construct();
}
public function addAPI( $xml ){
if( !file_exists( $xml ) ){
throw new Exception( "'{$xml}' is not found." );
}
$xmlApi = simplexml_load_file( $xml );
foreach ($xmlApi->category as $category) {
$catName = (string)$category['name'];
if( !is_array( $this->api[$catName] ) ){
$this->api[$catName] = array();
}
foreach ($category->endpoint as $endpoint) {
$this->api[$catName][(string)$endpoint['name']] = $endpoint;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment