Exemple #1
0
 /**
  * Set a callback function to be called after each request.
  *
  * The callback function is passed four parameters:
  * $url      - The requested URL
  * $response - The response of the cURL request
  * $info     - Information regarding the cURL request
  * $handle   - The cURL handle
  *
  * Whether the request was successful or failed, it will still call this
  * function.
  * @param mixed $callback A callable function to be made after each request.
  */
 public static function setCallback($callback)
 {
     try {
         if (is_string($callback) && function_exists($callback)) {
             self::$callback = $callback;
         } else {
             if (is_callable($callback)) {
                 self::$callback = $callback;
             } else {
                 throw new BattleNetAPI_Exception('The method setCallback() expects the parameter $callback to be a callable function. The function "' . $callback . '()" does not exist or is not callable.');
             }
         }
     } catch (BattleNetAPI_Exception $exception) {
         $exception->showMessage();
     }
 }