Topic: Accessing the ConfTool REST interface from a Linux bash script  (Read 57276 times)

Below you find some examples on how to access the ConfTool REST API from a Linux bash script. Please note that there is a ZIP file available.

We thank Joachim Neubert for providing the initial version of the script.

Code: [Select]
#!/bin/bash
# Idea and original file by Joachim Neubert, 15.8.2012
# Upates and additional comments by Harald Weinreich, 29.10.2013


# get xml export files for abstract, speaker and session data from conftool

URL="https://www.conftool.net/your_conference/rest.php" # Please enter your REST URL here.
#PASSWORD=`cat .secret` # use this if you have the password in a file called .secret
PASSWORD='********'     # or enter the passkey here
OUTPUTDIR="."           # relative or absolute directory without trailing /
ABSTRACT_FILE="./abstracts.xml"
SESSION_FILE="./sessions.xml"
SPEAKER_FILE="./speakers.xml"


# set common parameters for REST access
common_param="page=adminExport"               # mandatory to call export function
common_param+="&cmd_create_export=true"       # mandatory to execute export
common_param+="&form_include_deleted=0"       # include deleted / cancelled / withdrawn entries?
common_param+="&form_export_format=xml_short" # download format (xml, xml_short, csv_comma, xls...)
common_param+="&form_export_header=default"   # include header (for csv and excel export).


# parameters for abstract export
echo "Exporting abstracts..."

# create password hash salted with $TIMESTAMP used as nonce
# sha265sum returns a trailing "  -", so only get the first word
TIMESTAMP=`date +%s` # You may have to append "000" here if you also [u]se [/u]other scripts that use milliseconds for the nonce.
PASSHASH=`echo -n "$TIMESTAMP$PASSWORD" | sha256sum | awk '{print $1;}'`
ctdata="$common_param&nonce=$TIMESTAMP&passhash=$PASSHASH"
ctdata+="&export_select=papers"
ctdata+="&form_export_papers_options%5B%5D=abstracts"   # Additional parameter to include all abstracts.
ctdata+="&form_export_papers_options%5B%5D=authors_extended_email"
ctdata+="&form_export_papers_options%5B%5D=downloads"
#ctdata+="&form_track=3"  # Optional track selection
ctdata+="&form_status=p" # Optional status selection
curl --silent --request POST $URL --data "$ctdata" --output $OUTPUTDIR/$ABSTRACT_FILE

sleep 1 # required to make the nonce bigger than for the last call!


# parameters for session export
echo "Exporting sessions..."

# nonce and passhash generation same as above
TIMESTAMP=`date +%s`
PASSHASH=`echo -n "$TIMESTAMP$PASSWORD" | sha256sum | awk '{print $1;}'`
ctdata="$common_param&nonce=$TIMESTAMP&passhash=$PASSHASH"
ctdata+="&export_select=sessions"
ctdata+="&form_export_sessions_options%5B%5D=presentations"
ctdata+="&form_export_sessions_options%5B%5D=all"

curl --silent --request POST $URL --data "$ctdata" --output $OUTPUTDIR/$SESSION_FILE
sleep 1


# parameters for speaker export
echo "Exporting speakers..."

# nonce and passhash generation same as above
TIMESTAMP=`date +%s`
PASSHASH=`echo -n "$TIMESTAMP$PASSWORD" | sha256sum | awk '{print $1;}'`
ctdata="$common_param&nonce=$TIMESTAMP&passhash=$PASSHASH"
ctdata+="&export_select=subsumed_authors"
ctdata+="&form_status=p" # Status selection: Only authors of presented papers.

curl --silent --request POST $URL --data "$ctdata" --output $OUTPUTDIR/$SPEAKER_FILE

exit

General information on the ConfTool REST interface can be found at:
https://www.conftool.net/ctforum/index.php/topic,280.0.html,

Information about accessing the REST interface via PHP is available at:
http://www.conftool.net/ctforum/index.php/topic,282.0.html.