Register

ViewletQuiz - redirection of XML post

Questions regarding the authoring of Viewlets, installation or possible bugs with our products. For urgent issues, please use our support form on our website: http://www.qarbon.com/help/helpme.php
User
User avatar
Posts: 5
Joined: Thu Mar 08, 2007 10:52 am
Location: Toronto

ViewletQuiz - redirection of XML post

Postby oscarjr » Thu Mar 08, 2007 10:57 am

Hi there,

I was given a document on how to redirect the XML post of my ViewletQuiz surveys from http://services.qarbon.com/client/statsmailer to what ever URL I replace it with.

Does ViewletQuiz use HTTP POST to post the XML? Can I, in theory, redirect the post to a php script, for example:

http://mydomain.com/somescript.php

-oscar.

Site Admin
User avatar
Posts: 223
Joined: Fri May 26, 2006 1:51 pm
Location: Rochester, NY

Postby Andrew » Mon Mar 12, 2007 9:44 am

Yes, you can post the results to your PHP page. The XML is sent as raw data to the HTTP POST, not as a series of name/value pairs as is typical of HTTP POSTS. To get access to the raw POST data using $GLOBALS['HTTP_RAW_POST_DATA'] variable and the always_populate_raw_post_data configuration directive in php.ini
Andrew Branch

User
User avatar
Posts: 5
Joined: Thu Mar 08, 2007 10:52 am
Location: Toronto

Postby oscarjr » Mon Mar 12, 2007 6:46 pm

Andrew,

Thanks. I used php://input to read the raw post data but I only get the following data:

<report><end timedOut="false" completed="true" time="37899" /></report>

This looks to be the last XML post as per the word document that describes this process. For some reason, I am missing the question/answer XML post(s).

I know you cannot debug my php script but if you wanted to know what it was, it is:

<?php
$dest_xml='/<path>/viewlet.xml';
$file = fopen($dest_xml, "w", 0);
$putdata = fopen( "php://input" , "rb" );
while(!feof( $putdata )) {
fputs($file, fread($putdata, 4096));
}
fclose($putdata);
fclose($file);
?>

How do I get the other XML post(s)?

User
User avatar
Posts: 5
Joined: Thu Mar 08, 2007 10:52 am
Location: Toronto

Postby oscarjr » Wed Mar 21, 2007 8:47 am

Andrew,

I got my Web Hosting Provider to enable "always_populate_raw_post_data" in my php.ini.

But when I try to print (to a file) $GLOBALS['HTTP_RAW_POST_DATA'] to a file, I get an empty file.

What is the enctype that you are using to post the XML to my site?

BTW, here is my new and simple php code.

<?php
$dest_xml='/<path>/viewlet.xml';
$file = fopen($dest_xml, "w", 0);
fputs($file, $GLOBALS['HTTP_RAW_POST_DATA']);
fclose($file);
?>

-oscar.

User
User avatar
Posts: 5
Joined: Thu Mar 08, 2007 10:52 am
Location: Toronto

Postby oscarjr » Wed Mar 21, 2007 9:38 am

Nevermind. I solved my problem. I used php's php://input to read in the raw post data instead of using the $GLOBALS['HTTP_RAW_POST_DATA']. php recommends it because it is less memory intensive.

Here is php code that you can use to dump the survey results to a XML file on your own server (not on ViewCentral).

<?php
$putdata = fopen( "php://input" , "rb" );
$dest_xml='<path>/<XML filename>';
$file = fopen($dest_xml, "a", 0);
while(!feof( $putdata )) {
fputs($file, fread($putdata, 4096));
fputs($file, "\n");
}
fclose($putdata);
fclose($file);
?>

The key here is that Qarbon posts several and separate XML files to your server (to your php code/file) and you need to append to a file.

Hope this helps someone.

Next step, parse the XML code and push it to a MySQL database.

User
Posts: 1
Joined: Fri May 04, 2007 2:24 pm
Location: Fountain Valley, CA

How to do a single post at the end of the quiz?

Postby btnguyen » Tue May 08, 2007 2:19 pm

Does anyone know how to configure ViewletQuiz to perform a single post with the the entire XML file to a webpage at the end of the quiz?
Currently, I am receiving multiple post from ViewletQuiz to my page which make it difficult to determine which question and result is for which user.
Brian Nguyen

User
User avatar
Posts: 5
Joined: Thu Mar 08, 2007 10:52 am
Location: Toronto

Postby oscarjr » Tue May 08, 2007 5:09 pm

According to Qarbon, that is how ViewletQuiz is designed. Every time you submit a question, the .SWF will post that particular XML.

However, apparently, each user has a session in a cookie and we are suppose to be able to acquire the session's id so that we can tell which XML post is for who.

Unfortunately, I haven't learned this part yet but once I do, I'll post something.

I have the same issue with surveys.

Return to Discussions

Who is online

Users browsing this forum: No registered users and 1 guest