You've lost me now :)
You can't run javascript in an action because for the most part actions don't render content, and for webservices it's not even being displayed in a browser. Sounds like you're probably mis-using actions for something.
You don't need to use actions for web service callbacks. Web services are already protected by PAM tokens. It does create code duplication, but you can use a web service method callback from within an action if you are trying to avoid duplication.
Yeah, I assumed he just wanted to use an existing action for convenience to prevent duplication, but not sure after the last post.
Hello Steve,
is there an option to trigger an action inside of an API method? Something like:
elgg_ws_expose_function("machine.authenticate", "process_authentication_request",...
function process_authentication_request() { $encodedRequest = file_get_contents("php://input"); $request = json_decode($encodedRequest); $userID = $request->userId; $machineID = $request->machineId; if (verify_authentication($userID, $machineID)) { action('example_action'); } else { ... } }
When I'm trying to trigger the example_action it doesn't work. Why?
There's no reason it shouldn't work - however conditions for the action need to be met.
eg. If it's registered for logged in users it will fail if you're not logged in. If it can't find valid action tokens in the request it will fail.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.