0

I've just migrated to a new server, still linux based. After moving I saw a change in behavior - for some reason the order id send by the facebook credits callback in the payload formatted as : 2.6040261734251E+14 instead of : 143121239125639 (these are not necessarily the same order numbers, just refer to the format)...

The format arrives like that directly when taken from the $_REQUEST, and before the DB insert... Anyone has any idea maybe why would the format change/arrive like that? Thanks!

--- edit --- I'm getting the variable from the signed request using the parse_signed_request function:

    function parse_signed_request($signed_request, $secret) {
  list($encoded_sig, $payload) = explode('.', $signed_request, 2);

  // decode the data
  $sig = base64_url_decode($encoded_sig);
  $data = json_decode(base64_url_decode($payload), true);

  if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
    error_log('Unknown algorithm. Expected HMAC-SHA256');
    mail('example@example.com','server error','Unknown algorithm. Expected HMAC-SHA256');
    return null;
  }

  // check signature
  $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
  if ($sig !== $expected_sig) {
    error_log('Bad Signed JSON signature!');
    return null;
  }

  return $data;
}

As Charley P. noticed, i'm indeed using a 32 bit server instead of the 64 bit previous server. Could that somehow ruin the function above which uses

json_decode(base64_url_decode($payload), true);

Thanks again...

Charley P.
  • 184
  • 1
  • 13
Yanipan
  • 664
  • 1
  • 10
  • 28

1 Answers1

0

Your old server must have been 64bit and your new server is 32bit

Try to use the original numbers as string

Charley P.
  • 184
  • 1
  • 13
  • Thanks for the answer... I'm not doing any numeric manipulation on the value, I just pass it true facebooks parse_signed_request function when getting it from the signed request to decode it... any idea maybe i'm in a bit of a dead end... – Yanipan Nov 22 '11 at 07:09
  • @Yanipan So the problem is with the final number in your database? Could you provide an example of the code you use to insert the number into your table? – Charley P. Nov 22 '11 at 07:55