计算 vkontakte.ru iframe 应用程序的签名
为什么这个简短的 PHP 脚本:
<?php
$args = array(
'api_id' => $_GET['api_id'],
'method' => 'getProfiles',
'sid' => $_GET['sid'],
'uids' => $_GET['viewer_id'],
'v' => '3.0',
);
$req = $_GET['api_url'] . '?sig=' .
calc_sig($_GET['viewer_id'], $args, $_GET['secret']);
foreach ($args as $key => $val)
$req .= "&$key=$val";
$page = file_get_contents($req);
header('Content-Type: text/plain');
print_r($_GET);
print("\n\n req: " . $req);
print("\n\n page: " . $page);
function calc_sig($viewer_id, $arr, $secret) {
$kv = array();
foreach ($arr as $key => $val) {
if ($key != 'sid')
$kv[] = "$key=$val";
}
sort($kv);
$str = $viewer_id . join('', $kv) . $secret;
print("\n\n str: " . $str);
return md5($str);
}
?>
打印错误:
str: 59751265api_id=1762950method=getProfilesuids=59751265v=3.0a551fa3416
req: http://api.vkontakte.ru/api.php?sig=490142d9c3eb65ee64045a2ea754266c&api_id=1762950&method=getProfiles&sid=1bc83d2ed0db52b8ad45d8ddf36780f52944d5f6340ffa47ad5fef9594&uids=59751265&v=3.0
page: <?xml version="1.0" encoding="utf-8"?>
<error>
<error_code>4</error_code>
<error_msg>Incorrect signature</error_msg>
......
?>
我继续阅读 文档< /a> 一次又一次...
Why does this short PHP script:
<?php
$args = array(
'api_id' => $_GET['api_id'],
'method' => 'getProfiles',
'sid' => $_GET['sid'],
'uids' => $_GET['viewer_id'],
'v' => '3.0',
);
$req = $_GET['api_url'] . '?sig=' .
calc_sig($_GET['viewer_id'], $args, $_GET['secret']);
foreach ($args as $key => $val)
$req .= "&$key=$val";
$page = file_get_contents($req);
header('Content-Type: text/plain');
print_r($_GET);
print("\n\n req: " . $req);
print("\n\n page: " . $page);
function calc_sig($viewer_id, $arr, $secret) {
$kv = array();
foreach ($arr as $key => $val) {
if ($key != 'sid')
$kv[] = "$key=$val";
}
sort($kv);
$str = $viewer_id . join('', $kv) . $secret;
print("\n\n str: " . $str);
return md5($str);
}
?>
print the error:
str: 59751265api_id=1762950method=getProfilesuids=59751265v=3.0a551fa3416
req: http://api.vkontakte.ru/api.php?sig=490142d9c3eb65ee64045a2ea754266c&api_id=1762950&method=getProfiles&sid=1bc83d2ed0db52b8ad45d8ddf36780f52944d5f6340ffa47ad5fef9594&uids=59751265&v=3.0
page: <?xml version="1.0" encoding="utf-8"?>
<error>
<error_code>4</error_code>
<error_msg>Incorrect signature</error_msg>
......
?>
I keep reading the doc again and again...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,这有效:
Ok, this works: