phpfacebook-credits

facebook credit callback, order_id changes format changes after moving to a new server


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...


Solution

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

    Try to use the original numbers as string