Commit 47298e9e authored by Imran Hussain's avatar Imran Hussain

Inital code dump of working solution.

parents
#!/bin/bash
eub=$(curl -s 'https://www.swansea-union.co.uk/organisation/salesreports/6613/' -b ../cookies.txt --data '__EVENTTARGET=ctl00%24ctl00%24Main%24AdminPageContent%24lbPurchasers&__EVENTARGUMENT=&__VIEWSTATEGENERATOR=9B3E427D&ctl00%24ctl00%24Main%24AdminPageContent%24drDateRange%24txtFromDate=01%2F09%2F2015&ctl00%24ctl00%24Main%24AdminPageContent%24drDateRange%24txtFromTime=00%3A00&ctl00%24ctl00%24Main%24AdminPageContent%24drDateRange%24txtToDate=31%2F08%2F2016&ctl00%24ctl00%24Main%24AdminPageContent%24drDateRange%24txtToTime=00%3A00&ctl00%24ctl00%24Main%24AdminPageContent%24ReportViewer1%24ctl09%24VisibilityState%24ctl00=ReportPage' --compressed | grep -Po '(?<="ExportUrlBase":")[^"]+' | sed -e 's/\\u0026/\&/g')
#echo $eub
curl -s "https://www.swansea-union.co.uk${eub}XML" -b ../cookies.txt | xml2json
#!/bin/bash
source ../logindetails.sh
#echo ${username}
#echo ${password}
curl -c ../cookies.txt -d "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=ncivVUrwj8M408BNVHdQqraKgSaHmN8eEqiTO4rdgBvGKTKh09MJUJ3pqZ0YppTzaNaj94ECmjDrpBIRhHStoMP9F2rlTiTf82SkdivwyD8TrB%2F%2B8MyCgxTiq8AlKb9PmLs%2F%2BYu%2BQMOSHi1T406Jzep5YWF3Lcayzyv7KEeEGGxxp5VQ9gOQcEGTebZAXl0rAv8blZUKpatemKqUUNqFc2Xbow3C3mZ0pkoZgwzrePD0O0%2FgWtZcJGxVFmmDyQ3xrLfS22SkrDKxSgKLuXvOLpXHKC6grA1yaDma8%2BKFzO6HkITfvIDngNcis5E66OntWskb9geegI80QYsCWrsFQEEJe7lndHsyf%2BIhmXX3tpGpbb5TcS9i6%2BS8A59JheDG5US3MhzyJ0g3j5s%2BJBcC%2BWmSnnxWJFSXCUfWZTAzmNrJHu7AMeomoVY3k06f7BdOZao9q6bur%2FR7Bd%2F9LOhZB9nQnLwS0p3gHLov68j7ow%2F34HOLgSk6u%2B4QJuquiCRWBd1oTRKz9BPNAm8JlLUTN3YmuXGtpvesBdfUoOeEQVmRpPNH3qts13pEdCe8YdsamI2msN1qGkFIRdm6zZb5sUiL63P3W%2BV7Lcx7zY1DsQgTKKprHZqLpIOigjlkA1kPzkT9SK1ss890TQ8KeUvZYEKr81prB2Q%2Fo0FcHHI6tAd1WQAOEhLVJe0eW%2FVMGDxn8CZE2%2BgdfpMU5qlHz4qstf4ykQdc9dT0Bu7Hjm%2FUmHn3DtCSFw9538gLjxD0eJL37tc7Yx%2B%2FHPs%2FSe7EG6H%2Bk78V%2FhziQuPT6smxy9Y%2FJFhIBjA6P7N%2BKrygGruIADw%2FZAU6tO%2B2OsX8HrM1os%2F%2B8M7gJZgZc29gu6ZCkjU7uNIYx2x1JdnTF1%2BXPujcN7p9C9FD%2FWSUAv5%2BrY%2BtMP%2FFm9P8mv17i78bgr%2Fbq10sDwWr13OTu%2FwKtP4%2BQgUndC0meGN0fC14o2izTdlsdcyxmgUESH0%3D&__VIEWSTATEGENERATOR=7CD7556D&ctl00%24logincontrol%24UserName=${username}&ctl00%24logincontrol%24Password=${password}&ctl00%24logincontrol%24btnLogin=Log+In" https://www.swansea-union.co.uk/login/
<?php
/*
* SUCS SU-APIv2
* Imran Hussain - imranh@sucs.org
* Stuart John Watson - ripp_@sucs.org
*
* Use to lookup SUCS membership data from the Swansea University Students Union
* website. Calls a shell script which is just a curl command that logins in and
* saves the cookies to a file. Calls the next script which uses those cookies to
* curl the curl website again, quering it for memebrship data related to SUCS in
* XML format. It's then passed to xml2json where it is then echo'd out.
* The SUCS site then does its thang with it all
*/
// We want errors! When do we want them? Now!
error_reporting(E_ALL);
ini_set('display_errors', 1);
// path to scripts
$PATH = "./";
// get teh login cookie
exec($PATH."getcookie.sh");
// get the xml convert it to json and spit it out!
echo(shell_exec($PATH."dumpdata.sh"));
?>
SUCS SU-APIv2
Imran Hussain - imranh@sucs.org
Stuart John Watson - ripp_@sucs.org
Why?
====
The old SU-API wasn't written by us and a massive pain in the arse to maintain.
Not only did it require playing the game of SU polotics but it was also
horrible. It also required us to use windows server.
This, while still a nasty hack, is easier to maintain (less code) and better
in every way.
How does I use?
===============
https://<username>:<password>@su-apiv2.sucs.org/
And if you have a correct login it'll spit out some json
How does I get login?
=======================
If you ahve to ask you don't.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment