blopa/Magento-Chatbot

Webhook URL generation problem

dominik04u opened this issue · 3 comments

When I try to verify my Callback URL in FB app I have callback message like "The URL couldn't be validated. Response does not match challenge, expected value="1717583312", received="{"status":"success"}" "

I configurated all options in magento and status is of course "success", but why facebook want numeric value?

I have already read issues #31 and #60

I don't have any idea what is wrong or what I do wrong.

This is my URL: https://demo.onlineua.org/index.php/chatbot/chatdata/facebook/key/mr686WIBBp/

blopa commented

Hello @dominik04u. First of all, thanks for using our module.

I got many issues requests about the Facebook Challenge Hub. This was hard to code because I needed to create a "pure text" page with no HTML tags.

Some modules add blocks to all Magento pages and it may overwrite the webhook URL, which must NOT contain any blocks. Try looking for these blocks and exclude the itby adding <remove name="BLOCK_NAME" /> at Magento-Root/app/design/frontend/base/default/layout/werules_chatbot.xml

You should also check the URL like in this #60 (comment)

Please try that and let me know.

I changed your code a little. I changed this method:

`public function verifyWebhook($hub_token) {
			if ($this->data['hub_verify_token'] == $hub_token) {
				return $this->data['hub_challenge'];
			}
			return false;
		}

to this:

public function verifyWebhook($hub_token) {
			if ($_REQUEST['hub_verify_token'] == $hub_token) {
				return $_REQUEST['hub_challenge'];
			}
			return false;
}

because it always was null in my case., because $rawData = file_get_contents("php://input"); always was null. Then the URL callback in fb was saved. I send messages to my bot, but it still doesn't work. I don't know why php://input was null, and I don't know if messages are receive. Do you have idea what can be wrong?

--UPDATE--

I added this in php.ini

allow_url_fopen = on

allow_url_include = on

Callback URL works only with $_REQUEST

Ok. I repaired this, but I have another problem. Your plugin wants information like
$this->data["entry"][0]["messaging"][0]["referral"]["ref"]
or
$this->data["entry"][0]["messaging"][0]["postback"]["payload"];
but request from facebook doesn't have them.