? Php $ api_keyxxx; $ secretxxx; $ urlrest. kaixin001.comapirest. php; $ session_key $ _ GET [session_key]; if (empty ($ session_key) {$ session_key $ _ COOKIE [kx_connect_session_key];} else {setcookie (kx_connect_sess
? Php $ api_key = 'xxx'; $ secret = 'xxx'; $ url = 'HTTP: // rest.kaixin001.com/api/rest.php'; $ session_key = $ _ GET ['session _ key']; if (empty ($ session_key) {$ session_key = $ _ COOKIE ["kx_connect_session_key"];} else {setcookie ("kx_connect_sess
$ Api_key = 'xxx ';
$ Secret = 'xxx ';
$ Url = 'HTTP: // rest.kaixin001.com/api/rest.php ';
$ Session_key = $ _ GET ['session _ key'];
If (empty ($ session_key )){
$ Session_key = $ _ COOKIE ["kx_connect_session_key"];
} Else {
Setcookie ("kx_connect_session_key", $ session_key, time () + 3600*4 );
}
$ Param = array ('api _ key' => $ api_key, 'method' => 'users. getinfo', 'uid' => '100 100', 'format' => 'json', 'session _ key' => $ session_key ,);
$ Query = buildQuery ($ param, $ secret );
$ Result = postRequest ($ url, $ query );
$ Result = json_decode ($ result );
Function buildQuery ($ param, $ secret ){
$ Param ['call _ id'] = microtime (true );
$ Param ['V'] = '1. 0 ';
Ksort ($ param );
$ Request_str = '';
Foreach ($ param as $ key => $ value ){
$ Request_str. = $ key. '='. $ value; // No delimiter
}
$ Sig = $ request_str. $ secret;
$ Sig = md5 ($ sig );
$ Param ['sig '] = $ sig;
$ Query = http_build_query ($ param );
Return $ query;
}
Function postRequest ($ url, $ post_string ){
$ Useragent = 'kaixin001. com API PHP5 Client 1.1 (curl) '. phpversion (); $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ url );
If (strlen ($ post_string)> = 3 ){
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ post_string );
}
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true );
Curl_setopt ($ ch, CURLOPT_USERAGENT, $ useragent );
Curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, 10 );
Curl_setopt ($ ch, CURLOPT_TIMEOUT, 30 );
$ Result = curl_exec ($ ch );
Curl_close ($ ch );
Return $ result;
}
Function url_base64_encode ($ str ){
$ Search = array ('+ ','/');
$ Replace = array ('*','-');
$ Basestr = base64_encode ($ str );
Return str_replace ($ search, $ replace, $ basestr );
}