When implementing the Facebook data deletion request, Facebook calls my method from their side and is telling me that the json response im sending back to them is not what they are expecting to receive. If you look at their documentation here Facebook Data Deletion Request. The response back to Facebook should be as follows
{ url: '<url>', confirmation_code: '<code>' }
The code Facebook posts in order to return this json is this
$data = array(
'url' => $status_url,
'confirmation_code' => $confirmation_code
);
echo json_encode($data);
Which does not create what Facebook is intending as a response. There literally needs to be no quotes around the name of the property and single quotes around the actual values. So I built that out using this
$return_value = "{ url: '$url', confirmation_code: '$confirmation_code' }";
Yes still no success. IM kind of at a loss here since I've been trying various methods with response()->json()
json_encode()
when returning either the $data array or $return string I create. That ends up putting double quotes around the entire string or put in escape characters around the url, which is think is one of the reasons why they are telling me the json is not what they are expecting. So if any one has a clue as to exactly how Facebook wants this response to look like. Please let me know. Thank you for your help
public function removeFBDataCallback(Request $request)
{
$signed_request = $request->get('signed_request');
$data = $this->parse_signed_request($signed_request);
$fb_user_id = $data['user_id'];
$fb_user = $this->UsersRepository->CheckFacebookUIDExisted($fb_user_id);
if (!$fb_user) {
error_log("No user with facebook id: $fb_user_id found when trying to remove data during facebook deletion callback");
return response()->json(['code' => 403, 'data' => ['message' => 'Facebook user not found when deleting facebook data']]);
}
else {
$fb_delete_confirmation = new FBDeleteConfirmation();
$fb_delete_confirmation->facebook_id = $fb_user->facebook_user_id;
$fb_delete_confirmation->token = genToken(20);
$fb_delete_confirmation->save();
$fb_user->is_account_facebook = 0;
$fb_user->facebook_user_id = null;
$fb_user->save();
$confirmation_code = base64_encode("abc123");
$url = url('login').'/facebook'.'/dataDeleteConfirmation'.'?confirmationid'.('=').($confirmation_code);
error_log('------------------');
$return_value = "{ url: '$url', confirmation_code: '$confirmation_code' }";
error_log($return_value);
return json_encode($return_value);
}
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/jVORkd3
via IFTTT