Jump to content

REST API Bug


The Britain

Recommended Posts

Hey I don't mean to blow up your forums with a few threads, and I'm trying to genuinely solve these problems before I come here, but this one has be stumped a bit.

I'm creating a rest api for the site to use, and I can't seem to get the /core/hello to work let alone anything else. I've setup the key as such.

image.thumb.png.24b21f68f0270655e1c8e394569d5ec3.png

I then used the example snippet, modified of course.

$communityUrl = 'http://test.accursedfarms.com/';
$apiKey = '00a75c3993dc5a20fade6f9150f14645';
$endpoint = '/core/hello';
	
$curl = curl_init( $communityUrl . 'api' . $endpoint . '?key=' . $apiKey );
curl_setopt_array( $curl, array(
	CURLOPT_RETURNTRANSFER	=> TRUE,
) );
$response = curl_exec( $curl );

echo $communityUrl . 'api' . $endpoint . '?key=' . $apiKey;
echo "<br />";
echo $response;

And I keep getting this generic failure.

image.png.6e5494c1e251f2d98f7aaabd7054d019.png

This is baffling me a bit, as I have no IP restrictions turned on, mod_rewrite is working as expected, and I added the suggested mod_rewrite to my /root/api folder from the documentation.

This is my root level mod_rewrite .htaccess. I tried removing this .htaccess all together as it didn't seem needed, but it didn't help. The documentation says this means invalid characters, but everything seems to be setup correctly.

<IfModule mod_rewrite.c>
 Options -MultiViews
 RewriteEngine On
 RewriteBase /
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule \.(jpeg|jpg|gif|png)$ /public/404.php [NC,L]

 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]
 </IfModule>

And this is my /root/api level mod_rewrite .htaccess.

<IfModule mod_setenvif.c>
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
</IfModule>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /api/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>

Any help or suggestions are appreciated. Maybe it has to do with pages and the fact that the root domain lands on a page instead of the forums? I have no idea what could be causing this.

This is the closest thing I can find to an answer, and it doesn't work.

https://webflake.sx/topic/23248-rest-api-getting-3s2903-invalid_app/

Link to comment
Share on other sites

3 minutes ago, bfarber said:

Your mod_rewrite isn't working, so you have to use /index.php?/ in your URL.

http://test.accursedfarms.com/api/index.php?/core/hello&amp;key=00a75c3993dc5a20fade6f9150f14645

I'll be damned. Thank you.

Not to press your generosity, but do my .htaccess files look right? I have no idea how to proceed to get the mod_rewrite working.

Link to comment
Share on other sites

On the surface, yes, however (1) the server config needs to have AllowOverrides enabled, and (2) of course the mod_rewrite module needs to be enabled. I would contact your host about that to see why the htaccess files to enable mod_rewrite aren't working.

Link to comment
Share on other sites

Just now, bfarber said:

On the surface, yes, however (1) the server config needs to have AllowOverrides enabled, and (2) of course the mod_rewrite module needs to be enabled. I would contact your host about that to see why the htaccess files to enable mod_rewrite aren't working.

Ah, I just assumed mod_rewrite was working because nothing was throwing an error. I guess I shouldn't just assume things. Thank you again for your help!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...