schedule(array( * 'url' => 'http://google.com', * 'delay' => 60, // seconds * 'retries' => 10 * )); * * API Key and Secret Key are available here: https://api.hostmybot.com */ /******************************************************************************/ class HostMyBot { protected $api_url = 'https://api.hostmybot.com/v1/%s?%s'; protected $api_key; protected $secret_key; /**************************************************************************/ public function __construct($api_key, $secret_key) { $this->api_key = $api_key; $this->secret_key = $secret_key; } /**************************************************************************/ public function __call($method, $args) { $params = $args[0]; $params['api_key'] = $this->api_key; $params['sign'] = $this->sign($params); $url = sprintf($this->api_url, $method, http_build_query($params)); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); return $res ? json_decode($res, $is_object = true) : false; } /**************************************************************************/ protected function sign($params) { $str = $this->secret_key; ksort($params, SORT_STRING); foreach ($params as $key => $val) { $str .= $key; $str .= $val; } return md5($str); } }