Neil Neil - 2 years ago 91
JSON Question

Magento - Create AJAX endpoint that does not require a key

Im trying to create and endpoint in Magento that can be accessed externally. So I have this in my module controller

public function jsonAction()
{
$json = json_encode(['test' => 'test']);
$this->getResponse()->setHeader('Content-type', 'application/json');
$this->getResponse()->setBody($json);
}


If I use the below

$test = Mage::helper("adminhtml")->getUrl("test/test/json");


it generates a url with a key on the end and then the url like below:

http://test.app/index.php/test/test/json/key/b4070b1261af163467793da673a4df4a/

This works as expected and the JSON is returned.

The problem is that I need to be accessible from an external site that wont be able to generate the key so Im trying to get it to work just with

http://test.app/index.php/test/test/json

Any help would be much appreciated

Magneto module config.xml

<routers>
<test>
<use>admin</use>
<args>
<module>Test</module>
<frontName>test</frontName>
</args>
</test>
</routers>

Answer Source

I resolved this issue by creating a SOAP endpoint and on extension installation I create a Soap user with the correct roles to use the endpoint

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download