Facebook Credits签名请求:买家,收件人和user_id之间有什么区别

时间:2011-10-10 16:59:13

标签: php facebook api credits

我们正在使用PHP API和回调在我们的应用上添加一个购买按钮。

在签名的请求中,我有买家和接收者。在其他$ _REQUEST变量中,我得到了user_id。

当从某些帐户调用时,这三个都是相同的值,并且这三个都是我们正在使用的帐户的Facebook用户ID。这完全符合预期。

然而,有时候,买方和接收方与user_id不同。在这种情况下,user_id是facebook帐户的预期值,但买家和收件人对我们(或我们的应用程序)无法识别。

我们正处于进一步隔离的过程中 - 不知道这是特定于帐户,特定于会话还是其他内容。

编辑添加买家和收件人似乎是特定于会话的。

无论如何,我们真的想知道这三个领域的含义是什么,以及为什么它们有时相同或有时不同。如果你能告诉我们,或者给我们一些文件,那就太棒了。

1 个答案:

答案 0 :(得分:0)

  

目前,Facebook Credits signed_request将用户ID作为整数而不是字符串发送。 https://github.com/facebook/php-sdk/issues/221#issuecomment-503727

这对我有用: ...

//$data = json_decode(base64_url_decode($payload), true);
$data = json_decode( json_parse_num_to_str( base64_url_decode($payload) ), true);

...

/**
* @Mic_oss - Fast Solution
* json parse numeric value to string value
* @param JSON encoded string
* @return JSON encoded string w/ numeric values as string values
*/
function json_parse_num_to_str($strJson)
{
    if( !is_null($strJson) && !empty($strJson) )
    {
        $aJson = array();
        $aJson = explode('":',$strJson);
        foreach( $aJson as $sKeyJson => $sValueJson )
        {
            $aValueJson = array();
            $aValueJson = explode(',"',$aJson[$sKeyJson]);
            foreach( $aValueJson as $key => $value )
            {
                if( is_numeric($value) )
                {
                    $aValueJson[$key]='"'.$value.'"';
                }
            }
            $aJson[$sKeyJson] = implode(',"',$aValueJson);
        }
        $strJson = implode('":',$aJson);
    }
    return $strJson;
}
相关问题