Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get it working #1

Open
degreecy opened this issue Apr 19, 2022 · 2 comments
Open

Cannot get it working #1

degreecy opened this issue Apr 19, 2022 · 2 comments

Comments

@degreecy
Copy link

degreecy commented Apr 19, 2022

This is exactly what I’ve been looking for so thanks so much!

I know it's been a long time since this was posted but was exactly what I was looking for! Unfortunately I cannot get it working. In fact took quite a few work arounds to get Apache up and running with PHP (errors with Rewrite Engine missing).

However, I cannot get it it to call the web hook in home assistant. Config is updated to point to my specific HA server. When I do something like this, I just get the index.php returned from outside the "project folder".

http://192.168.0.7:8124/nfc/api/webhook/nfc-desk-light-5gNq_Ui8wKzqQ016q1wFONLi

returns http://192.168.0.7:8124/index.php

Is it something to do with permissions of the nfc folder (they are all under root ownership) ?

drwxr-xr-x 3 root root 4096 Apr 18 12:59 nfc

I can get a direct curl working from the html folder as follows:

<?php 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://192.168.0.4:8123/api/webhook/nfc-desk-light-5gNq_Ui8wKzqQ016q1wFONLi');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);


$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
?>

Finally, is something missing from the index.php file ??

<?php

$url = '192.168.0.4:8123/' . $_GET['route'];
$ch  = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_exec($ch);

echo '<script>window.close();</script>';

should it not end with ?>

Thanks!

@degreecy
Copy link
Author

I solved it. The issue is that if you have a seperate folder for a project under /html, then your .htaccess file does not work. The path to index.php needs updating with the project folder. In my case, /nfc/index.php needs adding to the .htaccess file......

@Spomsoree
Copy link
Owner

Awesome.

Didn't have time to check it yesterday, but glad you fixed it.

Feel free to create a pull request, if you feel like this fix could be helpful to others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants