Re: preview url

23 views
Skip to first unread message

Larry Weya

unread,
Jan 27, 2013, 3:45:21 AM1/27/13
to Martijn van de Rijdt, formh...@googlegroups.com
Hey Martijn,

I was posting to /webform/preview instead of /launch/get_survey_preview_url, it works fine now.

About possible changes to the API, from the formhub end, its much more flexible to have is such that we pass parameters to your /webform/preview url instead of posting, then getting the url before we can use it. I'm imagining a situation where the webform url can serve as a service to preview form xmls. It could be such that an application asks for permission to use the service from enketo, gets some kind of token that it can then re-use by simply posting the url to the form's xml.

At the moment, we have implemented the preview on the specific form page but if we were to add it to the form lis as well, it would mean making multiple posts to enketo just to retrieve the url on every page load.

I've copied the rest of the team to get their input on this as well.

On Fri, Jan 25, 2013 at 6:33 PM, Martijn van de Rijdt <mar...@aidwebsolutions.com> wrote:
Hey Larry,

I must admit, I don't know much about cURL, but this works:

curl -X POST -d "server_url=http://formhub.org/formhub_u&form_id=tutorial" http://enketo.formhub.org/launch/get_survey_preview_url

I actually got this snippet from you :)

So, it must have something to do with the --data-urlencode flag that shouldn't be there.

All the enketo APIs use the same so what you're using for the edit POSTs and for the Enter Webform POSTs can also be used for this.

Not planning to restrict access, but preferable to use the API to get access as I may want to change things around later once enketo is stable (in one month...). I really need to work on the PHP side of things but am waiting for CodeIgniter 3 which should have built-in support for PHPUnit testing.

Cheers,
martijn
On Fri, Jan 25, 2013 at 7:40 AM, Larry Weya <larr...@gmail.com> wrote:
Hey Martin,

I was trying to post to enketo to get the preview url using this command

curl -X POST --data-urlencode "server_url=http://formhub.org/larryweya" -d "form_id=tutorial" http://enketo.formhub.org/webform/preview

But enketo gives back - Preview requires server url and form id variables. What am I doing wrong?

I wanted to use this to generate a url for every form but since it didnt work I ended up generating the url in the form http://enketo.formhub.org/webform/preview?server=http://formhub.org/larryweya&id=tutorial and it works great. Are you planning on changing this functionality to only work with urls that enketo sends back from the POST?

--
Larry Weya



--
Aid Web Solutions - www.aidwebsolutions.com





--
Larry Weya

Martijn van de Rijdt

unread,
Jan 30, 2013, 5:43:48 PM1/30/13
to formh...@googlegroups.com, Martijn van de Rijdt
Hey Larry,

Ah yes, missed that url error...

If the POST to request the preview URL causes too much delay you can just craft the URL yourself in fh (but for previews only) with the query parameters ?server=https://formhub.org/formhub_u&id=something. You're right, it's probably better to do that. If it ever changes I'll create an issue on github.

Note that previews load slower than regular views (as they are not cached). See the other discussion on XSLT performance.

re. authentication, I don't quite understand what you mean, but we need to figure something out so that forms are more protected (I would like to first add support for the JavaRosa authentication API to enketo and then discuss what we need to add to fh/enketo). 
Reply all
Reply to author
Forward
0 new messages