Browse files

Improved args parsing, renamed error method

  • Loading branch information...
1 parent ce3916b commit ab72b701db087c6caefae6c52d47cf5212a54e87 @stas committed Apr 19, 2011
Showing with 9 additions and 4 deletions.
  1. +9 −4 EBAPI.class.php
View
13 EBAPI.class.php
@@ -124,7 +124,7 @@ function checkSecure( $value = true ) {
*
* @return null on no errors, Mixed data on error
*/
- function hasError() {
+ function getError() {
return $this->error;
}
@@ -145,8 +145,13 @@ function __call( $method, $args ) {
$query_data['password'] = $this->password;
// Parse args
- foreach ( $args as $k => $v )
- $query_data[ $this->api_methods[$method][$k] ] = $v;
+ if( is_array( $args ) )
+ $args = reset( $args );
+
+ if( $args )
+ foreach ( $this->api_methods[$method] as $k )
+ if( array_key_exists( $k, $args ) )
+ $query_data[$k] = $args[$k];
// Build the http query
$query_url = $this->api_url;
@@ -156,7 +161,7 @@ function __call( $method, $args ) {
$http_query = $query_url['scheme'] . '://';
unset( $query_url['scheme'] );
$http_query .= implode( '', $query_url );
- $http_query .= http_build_query( $query_data );
+ $http_query .= http_build_query( $query_data, '', '&' );
$response = file_get_contents( $http_query );
if( $response )

0 comments on commit ab72b70

Please sign in to comment.