"auth.getSession", "token" => $token ), false ); curl_setopt($ch, CURLOPT_URL,API_URL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($ch, CURLINFO_HEADER_OUT, true); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); if (curl_errno($ch)){ echo 'CURL Error: '. curl_error($ch); } curl_close($ch); $response = json_decode($response, true); // Append our other important values to successful signings if (!$response['error']){ $response['api_key'] = API_KEY; } return $response; } /** * Perform a signed request * * @param $data = array * @param $post = boolean (POST request) **/ function signRequest($data = array(), $post = true){ unset($data['action']); $ch = curl_init(); if (FALSE === $ch){ throw new Exception('Failed to initialize'); } // Make sure we've got our API key included $request = array_merge(array("api_key" => API_KEY), $data); // Loop all the values in our request and add to our signature $signature = ""; ksort($request); foreach ($request as $key => $value){ $signature.= $key.$value; } // Finalize the signature $signature.= API_SECRET; $signature = md5($signature); $request["api_sig"] = $signature; return $request; }