Quantcast
Channel: Topics in Category: Can I do this with LimeSurvey? - LimeSurvey forums
Viewing all articles
Browse latest Browse all 17529

Automatically pass a token to and execute a Python script - by: DenisChenu

$
0
0
Hi David,

Did you know if PHP have another way to 'knock' a python script ? PHP exec is always disable for security purpose but maybe another solution.

Else : you can call the same line directly in PHP using manual.limesurvey.org/AfterSurveyComplete and curl.

Some example of php script : framagit.org/SondagePro-LimeSurvey-plugi...enByResponse.php#L58
You just need the public function afterSurveyComplete()
and put a curl

Quickly done (not tested)
public function afterSurveyComplete() {
  $surveyId =$this->getEvent()->get('surveyId');
  $token = isset($_SESSION['survey_'.$surveyId]['token'] ? $_SESSION['survey_'.$surveyId]['token'] : null;
  if($token) {
    // There are surely another way to call a py script ???
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://localhost:8080/cgi-bin/Psychiatric%20Diagnostic%20Interview%20Print.py?surveyid=".$surveyId."&urltoken=".$token);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $output = curl_exec($ch);
    curl_close($ch);
  }
}

Viewing all articles
Browse latest Browse all 17529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>