VK API:签名不正确:sid&秘密授权

时间:2014-01-28 09:00:03

标签: php api vk

我正在尝试启动vk.com选项卡应用程序,我正在使用php api sdk,出于某种原因,当我尝试获取用户个人资料信息时,我得到了这个:

Incorrect signature: sid & secret authorization

代码就是休闲:

try {

$vkontakte = new VKontakte(array('testMode'   => true, 'fileUpload' => false));
$vkontakte->setApiId(XXXXXXX);
$vkontakte->setSecret('XXXXXXXXXX');

$viewerId = $vkontakte->getViewerId();

$profiles = $vkontakte->getProfiles(array(
    'uids'   => $viewerId,
    'fields' => 'nickname,sex,bdate,photo,photo_big,mobile_phone,has_mobile,home_phone,rate'
));
} catch (Exception $e) {
echo '<pre>';
echo $e->getMessage();
echo '</pre>';
}

知道这里可能有什么问题吗?或应该做什么?

1 个答案:

答案 0 :(得分:1)

我想你使用旧的api,尝试使用oauth api,参见文档:

http://vk.com/developers.php?oid=-1&p=%D0%90%D0%B2%D1%82%D0%BE%D1%80%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F_%D1%81%D0%B0%D0%B9%D1%82%D0%BE%D0%B2

您可以使用所有方法,仅用于获取access_token

获取访问令牌:

http://vk.com/developers.php?oid=-1&p=%D0%90%D0%B2%D1%82%D0%BE%D1%80%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F_%D1%81%D0%B0%D0%B9%D1%82%D0%BE%D0%B2

对于iframe应用,您在GET参数中获得了access_token,例如: APP_URL/?...&api_settings=8194&viewer_id=XXXX&viewer_type=2&sid=YOURSID&secret=FFFFFFFFFF&access_token=ACCESS_TOCKEN&group_id=0&is_app_user=1&auth_key=6dfa5e5f8179066e6a7d01281a238ed4&language=0&parent_language=0&ad_info=zz==&is_secure=0&ads_app_id=1111