开发者

Facebook Credits Signed Request: What is the difference between buyer, receiver, and user_id

开发者 https://www.devze.com 2023-04-12 05:05 出处:网络
We\'re in the process of putting a buy button on our app using the PHP API and callbacks. In the signed request, I have a buyer and a receiver. In other $_REQUEST vars, I get user_id.

We're in the process of putting a buy button on our app using the PHP API and callbacks.

In the signed request, I have a buyer and a receiver. In other $_REQUEST vars, I get user_id.

When called from some accounts, these three are all the same value, and all three are the facebook user id of the account we're using. This is exactly as expected.

However, sometimes, the buyer and receiver are different from the user_id. In this case, the user_id is the expected value for the facebook account, but the buyer and receiver are for no account we (or our app) recognize.

We're in the process of further isolation -- don't know yet if this is account-specific, session-specific, or something else.

edited to add that the buyer and receiver appear to be session-specific.

At any rate, we'd really like to know what the meanings of these three fields are, and why they are sometimes the same or sometimes different. If you can tell us, or point us at so开发者_运维知识库me documentation, that would be great.

Kim


Currently the Facebook Credits signed_request is sending the user IDs in as ints instead of strings. https://github.com/facebook/php-sdk/issues/221#issuecomment-503727

This works for me: ...

//$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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号