答卷api推送
<p>[TOC]</p>
<p>如果您需要将答卷数据备份到自己的服务器中,可以使用本接口,将提交的答卷Post到您指定的URL,并保存。</p>
<h1>一、数据推送API</h1>
<p>使用该接口,可以将填写者提交的数据推送到指定的URL,推送数据的格式是JSON,您需要提供接受数据的URL,并且在此URL上写程序接收数据。</p>
<p>数据PostURL:由您指定,但是必须为外网可访问的地址,如:<code>https://www.wjx.cn/demo/getapipost.aspx</code> (Demo地址)</p>
<p>推送数据示例:</p>
<pre><code class="language-csharp">{&quot;activity&quot;:&quot;5657754&quot;,&quot;name&quot;:&quot;问卷名称&quot;,&quot;timetaken&quot;:&quot;528&quot;,&quot;submittime&quot;:&quot;2016-08-23 10:01:59&quot;,
&quot;q1&quot;:&quot;1&quot;,&quot;q2&quot;: &quot;测试&quot;,&quot;q3&quot;,&quot;1,2&quot;,&quot;joinid&quot;:&quot;101812480275&quot;,&quot;totalvalue&quot;:&quot;15&quot;,&quot;sign&quot;:&quot;&quot;}</code></pre>
<p>推送参数说明:
注:系统会自动加上签名参数,参数名为"sign",计算方式为:sign=sha1(activity+index+推送密钥),其中activity和index代表问卷ID和作答序号,可以在推送数据中直接获取,推送密钥请联系尊享版客服获取。点击查看 [签名示例](<a href="https://www.wjx.cn/signsample.aspx?type=2">https://www.wjx.cn/signsample.aspx?type=2</a> "签名示例")
<img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/7db13b0b3399feacf276deb275de2c2c" alt="" /></p>
<h2>注意事项:</h2>
<p>(1)推送失败,可勾选“失败自动重发”选项。如连续推送失败超过<code>10</code>次,系统将不再向该url推送数据,<code>30</code>分钟后会继续发送,如果30分钟后还是失败,系统不会再次重发。</p>
<p>(2)如果使用了数据推送API,同时也使用了自定义链接参数,<code>sojumpparm</code>参数带进来的内容也会推送,无需使用“自定义链接参数”功能中的页面跳转传递参数。</p>
<p>(3)<a href="#shili">点击此处可以查看各题型的推送示例详情</a></p>
<h2>开发指南:</h2>
<p>1、PHP获取Json数据:可以使用<code>file_get_contents(&quot;php://input&quot;)</code>或者<code>$GLOBALS[&#039;HTTP_RAW_POST_DATA&#039;]</code></p>
<p>2、Python django:可以使用<code>request.raw_post_data</code>来获取<code>Json</code>数据</p>
<p>3、java代码:使用<code>org.apache.commons.io.IOUtils</code>来获取json字符串:</p>
<pre><code class="language-java">String jsonString = IOUtils.toString(request.getInputStream());
JSONObject json = new JSONObject(jsonString);</code></pre>
<p>4、C#代码:读取<code>Request.InputStream</code>数据:</p>
<pre><code class="language-csharp">Stream stream = Request.InputStream;
Byte[] byteData = new Byte[stream.Length];
stream.Read(byteData, 0, (Int32)stream.Length);
string jsonData = Encoding.UTF8.GetString(byteData);</code></pre>
<h1>二、获取题目选项对应文本内容</h1>
<p>在数据推送时,为保证推送速度及成功率,只会推送题目及选项对应的序号(推送的内容同按选项序号下载的内容一致,选择题为序号填空题为文本),不会推送题目及选项的文本内容,如需获取题目选项序号和文本的对应值,可以使用以下接口获取:</p>
<p>获取接口:<code>https://www.wjx.cn/handler/IllustrateApi.ashx?activityID=问卷ID</code></p>
<p>序号解释:</p>
<p>1.<code>q1、q2、q3</code>以此类推,代表每个题目的题干文字;</p>
<p>2.选择类的题目,<code>q1#1、q1#2、q1#3</code>分别代表第一个题的第一个、第二个、第三个选项;</p>
<p>3.多项填空题,只提供题干整体文本;</p>
<p>4.如果是矩阵单选或矩阵多选题,<code>q1</code>是题干文本,<code>q1_1,q1_2</code>是矩阵题的第一个、第二个左行标题,<code>q1_1#1,q1_1#2</code>分别是矩阵题第一个左行标题的,第一个选项、第二个选项内容。</p>
<p>5.矩阵填空,数据推送的时候直接推送的是选项内容,无需获取选项文本。类似的还有矩阵滑动条、表格下拉框、表格数值、表格文本题。</p>
<p>6.考试问卷,不包含正确答案的信息。</p>
<p>获取接口(JSON格式):<code>https://www.wjx.cn/handler/IllustrateApi.ashx?activityID=问卷ID&amp;JSON=1</code></p>
<h1>三、数据推送DEMO</h1>
<h2>1、设置测试推送地址</h2>
<p>将该地址: <code>https://www.wjx.cn/demo/getapipost.aspx</code> 放在数据推送的目标地址。注意,该地址仅用于测试,只显示最近<code>300</code>条推送数据。</p>
<h2>2、查看推送结果</h2>
<p>访问该地址:<code>https://www.wjx.cn/demo/getapipost.aspx</code> 可以查看测试DEMO获取到的数据详情。</p>
<h2>注意:</h2>
<p>测试环境,请勿推送敏感数据。</p>
<p><div id = "shili"></div></p>
<h1>四、各题型推送示例详情</h1>
<table>
<thead>
<tr>
<th style="text-align: left;">字段</th>
<th style="text-align: left;">说明</th>
<th>示例</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">activity</td>
<td style="text-align: left;">问卷ID</td>
<td>"22913715"(22913715为示例问卷id)</td>
</tr>
<tr>
<td style="text-align: left;">name</td>
<td style="text-align: left;">问卷名称</td>
<td>"测试数据推送api"(测试数据推送api为示例名称)</td>
</tr>
<tr>
<td style="text-align: left;">joinid</td>
<td style="text-align: left;">参与序号</td>
<td>"101488475952"(序号为问卷星所有参与者的序号)</td>
</tr>
<tr>
<td style="text-align: left;">timetaken</td>
<td style="text-align: left;">所用时间</td>
<td>"64"(64是参与时间是64秒)</td>
</tr>
<tr>
<td style="text-align: left;">submittime</td>
<td style="text-align: left;">提交答卷时间</td>
<td>"2018-04-23 19:57:52</td>
</tr>
<tr>
<td style="text-align: left;">totalvalue</td>
<td style="text-align: left;">总分</td>
<td>"59"</td>
</tr>
<tr>
<td style="text-align: left;">sojumpparm</td>
<td style="text-align: left;">来源详情</td>
</tr>
<tr>
<td style="text-align: left;">ipaddress</td>
<td style="text-align: left;">ip地址</td>
</tr>
<tr>
<td style="text-align: left;">nickname</td>
<td style="text-align: left;">微信昵称</td>
</tr>
<tr>
<td style="text-align: left;">thirdusername</td>
<td style="text-align: left;">第三方昵称</td>
<td>使用了密码列表,这里会显示每个密码列表对应的附加属性</td>
</tr>
</tbody>
</table>
<p>如使用了用户体系,会推送以下数据:</p>
<table>
<thead>
<tr>
<th style="text-align: left;">字段</th>
<th style="text-align: left;">说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">thirdusername</td>
<td style="text-align: left;">用户ID</td>
</tr>
<tr>
<td style="text-align: left;">realname</td>
<td style="text-align: left;">姓名</td>
</tr>
<tr>
<td style="text-align: left;">relDept</td>
<td style="text-align: left;">部门</td>
</tr>
<tr>
<td style="text-align: left;">relExt</td>
<td style="text-align: left;">附加信息</td>
</tr>
</tbody>
</table>
<h2>单选题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/e5ed1c955c2f17ff5afda8d2b8c6663c" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q1&quot;:&quot;1&quot;</code></pre>
<p>其中q1表示第一题,值“1”表示用户选择了第一个选项。</p>
<h2>多选题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/52ccb199bfc6c6942b9cdbf2d45d42d3" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q2&quot;:&quot;1,2&quot;</code></pre>
<p>其中q2表示第2题,值“1,2”表示用户同时选择了第1个和第2个选项。</p>
<h2>单项填空题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/a4690b94f4199aae9c1944d7c6d942b6" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q3&quot;:&quot;测试&quot;</code></pre>
<p>其中q3表示第3题,值“测试”表示用户输入的内容。</p>
<h2>矩阵量表题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/690b27466484765e300ac41e5cf8f6f6" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q4_1&quot;:&quot;1&quot;,&quot;q4_2&quot;:&quot;1&quot;</code></pre>
<p>其中q4_1表示第4题的第一个小题,即外观这个题目,值“1”表示选择第一个选项,q4_2表示第4题的第二个小题,即功能这个题目,值“1”表示选择第一个选项。</p>
<h2>矩阵单选题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/ef9f2486414d1a04d9bb06bd0d127cd7" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q5_1&quot;:&quot;5&quot;,&quot;q5_2&quot;:&quot;5&quot;</code></pre>
<p>其中q5_1表示第5题的第一个小题,即外观这个题目,值“5”表示选择第五个选项,q5_2表示第5题的第二个小题,即功能这个题目,值“5”表示选择第五个选项。</p>
<h2>矩阵填空题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/75ab5b45081859bcd0979b99c4529285" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q6_1&quot;:&quot;填空1测试&quot;,&quot;q6_2&quot; :&quot;填空2测试&quot;</code></pre>
<p>其中q6_1表示第6题的第一个空,值“填空1测试”表示用户输入的内容, q6_2表示第6题的第二个空,值“填空2测试”表示用户输入的内容。</p>
<h2>矩阵滑动条:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/0fb45644a4f290844aea03193e8ea954" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q7_1&quot;:&quot;62&quot;,&quot;q7_2&quot;:&quot;17&quot;</code></pre>
<p>其中q7_1表示第7题的第一个小题,62表示第一小题选择的分数是62分,q7_2表示第7题的第二个小题,17表示第一小题选择的分数是17分。</p>
<h2>表格下拉框:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/94bcd76b8d0cd557a28b108cbd76a182" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q8_1_1&quot;:&quot;很满意&quot;,&quot;q8_1_2&quot;:&quot;很满意&quot;,&quot;q8_1_3&quot;:&quot;很满意&quot;,&quot;q8_1_4&quot;:&quot;很满意&quot;,&quot;q8_1_5&quot;:&quot;很满意&quot;,
&quot;q8_2_1&quot;:&quot;满意&quot;,&quot;q8_2_2&quot;:&quot;满意&quot;,&quot;q8_2_3&quot;:&quot;满意&quot;,&quot;q8_2_4&quot;:&quot;满意&quot;,&quot;q8_2_5&quot;:&quot;满意&quot;</code></pre>
<p>其中q8_1_1表示第8题的第一个小题的第一个选项,即在外观这个小题中百度这个选项,选择的是“很满意”,依次类推。</p>
<h2>表格数值题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/4d1c4bfc00e4c909e5a0d57807768290" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q9_1_1&quot;:&quot;1&quot;,&quot;q9_1_2&quot;:&quot;1&quot;,&quot;q9_1_3&quot;:&quot;1&quot;,&quot;q9_1_4&quot;:&quot;1&quot;,&quot;q9_1_5&quot;:&quot;1&quot;,&quot;q9_2_1&quot;:&quot;2&quot;,&quot;q9_2_2&quot;:&quot;2&quot;,
&quot;q9_2_3&quot;:&quot;2&quot;,&quot;q9_2_4&quot;:&quot;2&quot;,&quot;q9_2_5&quot;:&quot;2&quot;</code></pre>
<p>其中q9_1_1表示第9题的第一个小题的第一个选项,即在外观这个小题中百度这个选项,填写的是“1”,依次类推。</p>
<h2>表格文本题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/75734ab3c31737bc3342a3f3acb22708" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q10_1_1&quot;:&quot;1&quot;,&quot;q10_1_2&quot;:&quot;1&quot;,&quot;q10_1_3&quot;:&quot;1&quot;,&quot;q10_1_4&quot;:&quot;1&quot;,&quot;q10_1_5&quot;:&quot;1&quot;,&quot;q10_2_1&quot;:&quot;2&quot;,&quot;q10_2_2&quot;:&quot;2&quot;,
&quot;q10_2_3&quot;:&quot;2&quot;,&quot;q10_2_4&quot;:&quot;2&quot;,&quot;q10_2_5&quot;:&quot;2&quot;</code></pre>
<p>其中q10_1_1表示第10题的第一个小题的第一个选项,即在外观这个小题中百度这个选项,填写的是“1”,依次类推。</p>
<h2>上传文件题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/863f4faaa8e95f98c7fe662039538862" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q11&quot;:&quot;http://pubuserqiniu.paperol.cn/22913715_2_q11_-bMdVn-C60qTgxjbRU5Bqg.png?download/2_11_logo.png&amp;e=1524571072&amp;token=-kY3jr8KMC7l3KkIN3OcIs8Q4s40OfGgUHr1Rg4D:su2PbUDBsALS9lbLzKAniWeEiys=&quot;</code></pre>
<p>其中q11表示的是第十一题,后面的链接为上传文件的下载地址。</p>
<h2>NPS量表题测试:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/b758eb59505a97bed54216969b3417e0" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q12&quot;:&quot;10&quot;</code></pre>
<p>其中q12表示第十二题,10表示选择的内容为10分。</p>
<h2>评分单选题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/0d5e03716400ee3a5bc6bed400f7da7f" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q13&quot;:&quot;1&quot;</code></pre>
<p>其中q13表示第13题,值“1”表示用户选择了第一个选项;</p>
<h2>评分多选题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/91a5e9fc5c51a1a163ea6f0d9f262893" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q14&quot;:&quot;1,2&quot;</code></pre>
<p>其中q14表示第14题,值“1,2”表示用户同时选择了第1个和第2个选项。</p>
<h2>排序题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/e78e5f13c6abb2f8c0afd668f1ca7372" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q15&quot;:&quot;1,2&quot;</code></pre>
<p>其中q15表示第15题,值“1,2”表示选项的排序为1、2。</p>
<h2>多级下拉框:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/6dffb5b861934ea4ddef64750ff0f954" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q16&quot;:&quot;中国-湖南&quot;</code></pre>
<p>其中q16表示第16题,"中国-湖南"表示一级选项中选择的是中国,二级选项中选择的是湖南。</p>
<h2>比重题测试:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/51e4dffdff6326c171cbdece9143428c" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q17_1&quot;:&quot;33&quot;,&quot;q17_2&quot;:&quot;67&quot;</code></pre>
<p>其中q17_1表示第17题的第一个小题,即外观这个题目,选择的比重为33,q17_2表示第17题的第二个小题,即性能这个题目,选择的比重为67。</p>
<h2>滑动条:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/fb7962cb9903e81f7addee961fd21ab9" alt="" />
推送形式:</p>
<pre><code class="language-csharp">q18&quot;:&quot;59&quot;</code></pre>
<p>其中q18表示第18题,选择的值为59。</p>
<h2>情景随机题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/744498100b999eba0dfa30d12ecf3eba" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q19&quot;:&quot;1&quot;</code></pre>
<p>其中q19表示第19题,1表示随机的情景为情景1。</p>
<h2>商品题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/4e2008a6544bfd2e15e1bff2dcfe30d5" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q20&quot;:&quot;1^1,2^1,3^1&quot;,&quot;index&quot;:&quot;3&quot;</code></pre>
<h2>评价题:</h2>
<p><img src="http://openapi.wjx.cn/server/index.php?s=/api/attachment/visitFile/sign/138f7427c6ed8226b5ab1bab51cc35f7" alt="" />
推送形式:</p>
<pre><code class="language-csharp">&quot;q1_3&quot;:&quot;业务不熟&quot;,&quot;q1&quot;:&quot;3&quot;</code></pre>
<p>其中q1表示第一题,3表示选择了第三个选项q1_3表示第三个选项中,选择了“业务不熟”这个标签</p>
<h2>测试问卷链接</h2>
<p><code>https://www.wjx.cn/jq/22913715.aspx</code></p>
<h2>查看推送结果</h2>
<p><code>http://wjxapi.paperol.cn/data.txt</code> (根据id22913715搜索即可)</p>