function http_build_query_for_curl($arrays, &$new = array(), $prefix = null) { if (is_object($arrays)) { $arrays = get_object_vars($arrays); } foreach ($arrays as $key => $value) { $k = isset($prefix) ? $prefix . '[' . $key . ']' : $key; if (is_array($value) or is_object($value)) { http_build_query_for_curl($value, $new, $k); } else { $new[$k] = $value; } } }
function _do_defensetroop() { $qty = $_GET['qty']; if ($qty < 1) { $qty = 1; } $url = $this->realm . "/api/cities/" . $this->_city . "/units.json"; $data = array('gangster' => $this->_wangsta, '_method' => 'post', '_session_id' => $this->_session, 'user_id' => $this->_user_id, 'city_id' => $this->_city, 'units[quantity]' => $qty, 'units[unit_type]' => $_GET['dTroopName'], 'units[include_requirements]' => 'false'); http_build_query_for_curl($data, $post); $this->_connection = curl_init(); // set user agent curl_setopt($this->_connection, CURLOPT_USERAGENT, $this->user_agent); // set the target url curl_setopt($this->_connection, CURLOPT_URL, $url); curl_setopt($this->_connection, CURLOPT_POST, 1); curl_setopt($this->_connection, CURLOPT_POSTFIELDS, $post); curl_setopt($this->_connection, CURLOPT_RETURNTRANSFER, true); // execute curl,fetch the result and close curl connection $this->_result = curl_exec($this->_connection); $this->_info = curl_getinfo($this->_connection); }
/** * Handles my 22oz curls, ok it sends the data via post atm. * @param string $url * @param mixed $data * @return Wangsta */ public function _do_beer_curls($url = '', $data = '') { http_build_query_for_curl($data, $post); $this->_connection = curl_init(); // set user agent curl_setopt($this->_connection, CURLOPT_USERAGENT, $this->user_agent); // set the target url curl_setopt($this->_connection, CURLOPT_URL, $url); curl_setopt($this->_connection, CURLOPT_POST, 1); curl_setopt($this->_connection, CURLOPT_POSTFIELDS, $post); curl_setopt($this->_connection, CURLOPT_RETURNTRANSFER, true); // execute curl,fetch the result and close curl connection $this->_result = curl_exec($this->_connection); $this->_info = curl_getinfo($this->_connection); // Request failed if (false === $this->_result) { $this->_error_code = curl_errno($this->_connection); $this->_error_msg = curl_error($this->_connection); echo cli_message(" SAY WHAT ONE MORE TIME I DARE YA!\n\n Error Code = {$this->_error_code}\n Error MSG = {$this->_error_msg}\n"); } else { $this->_parse_result(); echo cli_message("ATTACK RESULTS \n\t\tAO's Left = {$this->_aos_left}\n"); } curl_close($this->_connection); $this->debug(); die; return $this; }
function _do_slot() { $url = "http://realm183.c2.godfather.wonderhill.com/api/cities/" . $this->_city . "/npc_buildings/" . $this->_building . ".json"; $data = array('city_building_id' => $this->_building, 'gangster' => $this->_wangsta, '_method' => 'put', '_session_id' => $this->_session, 'user_id' => $this->_user_id, 'city_id' => $this->_city); http_build_query_for_curl($data, $post); $this->_connection = curl_init(); // set user agent curl_setopt($this->_connection, CURLOPT_USERAGENT, $this->user_agent); // set the target url curl_setopt($this->_connection, CURLOPT_URL, $url); curl_setopt($this->_connection, CURLOPT_POST, 1); curl_setopt($this->_connection, CURLOPT_POSTFIELDS, $post); curl_setopt($this->_connection, CURLOPT_RETURNTRANSFER, true); // execute curl,fetch the result and close curl connection $this->_result = curl_exec($this->_connection); $this->_info = curl_getinfo($this->_connection); }
function _do_slot() { //http://realm183.c2.godfather.rykaiju.com/api/cities/104223904/wildernesses/collect_all.json $url = "http://realm183.c2.godfather.wonderhill.com/api/cities/" . $this->_city . "/wildernesses/collect_all.json"; $data = array('gangster' => $this->_wangsta, '_session_id' => 'a41fdc6b8927d036a827ee05fba74381', 'user_id' => $this->_user_id, 'city_id' => $this->_city); http_build_query_for_curl($data, $post); $this->_connection = curl_init(); // set user agent curl_setopt($this->_connection, CURLOPT_USERAGENT, $this->user_agent); // set the target url curl_setopt($this->_connection, CURLOPT_URL, $url); curl_setopt($this->_connection, CURLOPT_POST, 1); curl_setopt($this->_connection, CURLOPT_POSTFIELDS, $post); curl_setopt($this->_connection, CURLOPT_RETURNTRANSFER, true); // execute curl,fetch the result and close curl connection $this->_result = curl_exec($this->_connection); $this->_info = curl_getinfo($this->_connection); }
function _do_redeem() { $url = "http://realm183.c2.godfather.rykaiju.com/api/bonds/redeem.json"; $data = array('gangster' => $this->_wangsta, 'action' => 'index', '_session_id' => $this->_session, 'user_id' => $this->_user_id, 'city_id' => $this->_city); http_build_query_for_curl($data, $post); $this->_connection = curl_init(); // set user agent curl_setopt($this->_connection, CURLOPT_USERAGENT, $this->user_agent); // set the target url curl_setopt($this->_connection, CURLOPT_URL, $url); curl_setopt($this->_connection, CURLOPT_POST, 1); curl_setopt($this->_connection, CURLOPT_POSTFIELDS, $post); curl_setopt($this->_connection, CURLOPT_RETURNTRANSFER, true); // execute curl,fetch the result and close curl connection $this->_result = curl_exec($this->_connection); $this->_info = curl_getinfo($this->_connection); }