WebInputStream vs cURL vs Browser (OnlineUnlock tutorial)

I have been playing along with the OnlineUnlockStatus tutorial.

I have implemented the test server on the web (rather than locally).

There’s a strange difference in behaviour among the demo app (which uses WebInputStream) vs cURL vs the browser (Chrome).

For a single URL https://mysite.com/api/authorisation?email=test%40juce.com&pw=test
there are three different responses:

  • Browser : Shows XML as expected.
  • cURL : Triggers exception on site.
  • WebInputStream (as implemented in unlock demo): 404 page.

Obviously this is not just a JUCE issue but I’m struggling to appreciate why these responses might be so different. Any thoughts would be really helpful.

The site uses OctoberCMS (based on Laravel) and uses Laravel Routes to create the API.


API implementation:
(in routes.php of a homemade OctoberCMS plugin)


Route::get('/api/authorisation', function () {

    $xmlResponse  = '<?xml version="1.0" encoding="utf-8"?>';

    if(htmlspecialchars($_GET["email"]) === "test@juce.com" and htmlspecialchars($_GET["pw"]) === "test")
        $xmlResponse .= '<MESSAGE message="Thanks for registering our product!"><KEY>[[[ generated key ]]]</KEY></MESSAGE>';
        $xmlResponse .= '<ERROR error="Sorry, we were not able to authorise your request. Please provide a valid email address and password."></ERROR>';

    return Response::make($xmlResponse)->header('Content-Type', 'text/xml');


Using WebInputStream::WebInputStream (url, false) [ for a get request instead of post ] solved the immediate issue but still curious about the difference in response since PHP $_GET is supposed to return post params as well. (Also curious about the cURL response since that was implicitly a get.) But perhaps this is more an OctoberCMS problem.

Well, you define your route via Route::get, which presumably only exposes the route as a GET request. Had you written Route::post, it would only have handled POST requests. Simple as that.

1 Like