PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 9, 2022

[FIXED] Remove the app_data from the signed request

 January 09, 2022     facebook-php-sdk, signed     No comments   

Issue

When i call my fb-app with a GET request, like "?app_data=1", the variable is in the signed request. Ok, so far. But, when i click to another link in my fb-app, the app_data is still in the signed request. My application reactes on it, but i don't need it again.

How can i remove the app_data in the signed request? Has anyone a suggestion for this problem?

I use the PHP and JS SDK.

$aSignedRequest = $_REQUEST['signed_request'];
if(isset($aSignedRequest))
{
    $sSignedRequest = $aSignedRequest['signed_request'];
    list($sEncodedSig, $sPayload) = explode('.', $sSignedRequest, 2);

    // decode the data
    $aData = json_decode(base64_decode(strtr($sPayload, '-_', '+/')), true);
    $iContestId = $aData['app_data'];
}

Solution

Here is the solution:

unset($aData['app_data']);
$sData = json_encode($aData);
$sPayload = base64_encode($sData);
$sEncodedSig = hash_hmac('sha256', $sPayload, '<<fb app-secret>>', $raw = true);
$sSignedRequest = base64_encode($sEncodedSig).'.'.$sPayload;
$_REQUEST['signed_request'] = $sSignedRequest;


Answered By - Andreas Lindner
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing