嗨,我在 php 中使用此代码检查是否喜欢使用 signed_request 的粉丝页面:
private function parsePageSignedRequest()
{
if (isset($_REQUEST['signed_request']))
{
$encoded_sig = null;
$payload = null;
list($encoded_sig, $payload) = explode('.', $_REQUEST['signed_request'], 2);
$sig = base64_decode(strtr($encoded_sig, '-_', '+/'));
$data = json_decode(base64_decode(strtr($payload, '-_', '+/'), true));
return $data;
}
return false;
}
function isLiked()
{
$signed_request = $this->parsePageSignedRequest();
if($signed_request->page->liked)
{
return true;
} else {
return false;
}
}
我如何为 python/django 编写这个?