I wrote a little program using the vkapi.class.php, I show the result on the browser.. cut and paste it
and works, but when I use the program.. show the Incorrect signature message!!
http://api.vkontakte.ru/api.php?api_id= ... =XXX&v=3.0
When I copy the result on the browser, always works.. not in my script using
Код: Выделить всё
$VK = new vkapi($api_id, $session['secret'], $session['mid'], $session['sid']); $resp = $VK->api('video.get', array('uid'=>'XXXXX')); <?php/** * VKAPI class for vk.com social network * * @package server API methods * @link http://vk.com/developers.php * @autor Oleg Illarionov * @changed: some changes by me * @version 1.0 */ class vkapi { var $api_secret; var $app_id; var $api_url; var $api_user; var $api_sid; var $params1; function vkapi($app_id, $api_secret, $api_user, $api_sid, $api_url = 'api.vk.com/api.php') { $this->app_id = $app_id; $this->api_secret = $api_secret; $this->api_user = $api_user; $this->api_sid = $api_sid; if (!strstr($api_url, 'http://')) $api_url = 'http://'.$api_url; $this->api_url = $api_url; } function api($method,$params=false) { if (!$params) $params = array(); $params['api_id'] = $this->app_id; $params['v'] = '3.0'; $params['method'] = $method; $params['timestamp'] = time(); $params['format'] = 'JSON'; $params['random'] = rand(1,10000); $params['callback'] ='VK.Api._callbacks[' . rand(1,999999) . ']'; ksort($params); $sid = array(); $sid[] = $this->api_user; foreach ($params as $k => $v) { $sid[] = "$k=$v"; } $sid[] = $this->api_secret; $params['sig'] = md5(join('', $sid)); $params['sid'] = $this->api_sid; $url = "http://api.vkontakte.ru/api.php"; $params1 = $this->params($params); echo $url . "?" . $params1; // work in the browser with cut and paste $ress = file_get_contents($url . "?" . $params1); // got the Incorrect signature message! } function params($params) { ksort($params); $pice = array(); foreach($params as $k=>$v) { $pice[] = $k.'='. urlencode($v); } return implode('&',$pice); }
Thanks in advance