Home > Mobile >  Codeigniter 3 rest whatsapp webhook verification
Codeigniter 3 rest whatsapp webhook verification

Time:12-14

I am trying to verify Whatsapp business webhook, codeigniter rest configuration format is set as below

$config['rest_default_format'] = 'json';

And sending the response using the following

$wchalng = $this->get('hub_challenge');
$this->response($wchalng, 200)

When i try to verify webhook, i receive the following error:

The URL couldn't be validated. Response does not match challenge, expected value="391067291", received="\"391067291\""

When I use postman, the result is "391067291" with double quotes, but it seems Facebook requires the result to be without any quotes 391067291. I tried using:

stripcslashes($this->response($wchalng, 200));
json_decode($this->response($wchalng, 200));

but none of the above worked! I also tried to change from json to html for the rest_default_format without any success.
Any help on how to get rid of the double quotes in codeigniter rest response would be highly appreciated.

CodePudding user response:

After trying different things, finally I was able to get a successful verification.
All I needed is to convert the received string into integer to remove the double quotes.

$wchalng = intval($this->get('hub_challenge'));
  • Related