Имею такой код:
<?
require 'vkapi.class.php';
$api_id = 2910988; // Insert here id of your application
$secret_key = 'fmbOO8SLWg0H3NBekYFu'; // Insert here secret key of your application
$VK = new vkapi($api_id, $secret_key);
//$resp = $VK->api('getProfiles', array('uids'=>'1,6492'));
$resp = $VK->api('wall.post', array('owner_id'=>'17741251', 'message' => 'qweqweqwe'));
print_r($resp);
?>
<?php
/**
* VKAPI class for vk.com social network
*
* @package server API methods
* @link http://vk.com/developers.php
* @autor Oleg Illarionov
* @version 1.0
*/
class vkapi {
var $api_secret;
var $app_id;
var $api_url;
function vkapi($app_id, $api_secret, $api_url = 'api.vk.com/api.php') {
$this->app_id = $app_id;
$this->api_secret = $api_secret;
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(0,10000);
ksort($params);
$sig = '';
foreach($params as $k=>$v) {
$sig .= $k.'='.$v;
}
$sig .= $this->api_secret;
$params['sig'] = md5($sig);
$query = $this->api_url.'?'.$this->params($params);
$res = file_get_contents($query);
return json_decode($res, true);
}
function params($params) {
$pice = array();
foreach($params as $k=>$v) {
$pice[] = $k.'='.urlencode($v);
}
return implode('&',$pice);
}
}
?>
На выходе получаю:
Array ( [error] => Array ( [error_code] => 4 [error_msg] => Incorrect signature: Session can be expired, revoked by user or connected with different IP address [request_params] => Array ( [0] => Array ( [key] => api_id [value] => 2910988 ) [1] => Array ( [key] => format [value] => json ) [2] => Array ( [key] => message [value] => qweqweqwe ) [3] => Array ( [key] => method [value] => wall.post ) [4] => Array ( [key] => owner_id [value] => 17741251 ) [5] => Array ( [key] => random [value] => 7404 ) [6] => Array ( [key] => timestamp [value] => 1334772077 ) [7] => Array ( [key] => v [value] => 3.0 ) [8] => Array ( [key] => sig [value] => accf1d951e833d0093f9450395298b1f ) ) ) )
Метод wall.get отлично работает, а post почему-то упирается. Что делать?