<?php // sorry // gib errars plox error_reporting(E_ALL); ini_set('display_errors', 1); // without this the entire thing doesn't work include_once("../suapiv2-key.php"); //SUCS Org ID According to the SU $orgid = "6613"; $apibaseurl = "http://su-apiv2.sucs.org/?apikey=${apikey}&orgid=${orgid}"; // Get the shit json the suapiv2 spits out $ch = curl_init($apibaseurl); curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE); $raw_data = curl_exec($ch); curl_close($ch); $formated_raw_data = json_decode($raw_data, true); //convert it into php arrays /* * $membership_data is an array where each type of memebrship is it;s own array * Insdie each of those arrays the actual arrary of members is under ["Detail_Collection"]["Detail"] * So $membership_data[0]["Detail_Collection"]["Detail"][0] will get you the array containing the * first member in the data */ $membership_data = $formated_raw_data["table1"]["table1_Product_Collection"]["table1_Product"]; // make a new array that just contains *every* member no matter what they bought $just_members = array(); foreach ($membership_data as $typeOfMember) { foreach ($typeOfMember["Detail_Collection"]["Detail"] as $member) { array_push($just_members, $member["@attributes"]); } } /* You can now use $just_members to probe member detials. It's an array of arrays which each contain: * transaction_id (recepit id) * purchaser (full name) * textbox6 (under 18 or not) NOT SURE OF THE FORMAT * card_number (student number) * shop_name (where they bought sucs memebrship) * qty (how many sucs memebrships they bought) * purchase_date (timestamp of when they bought memebrship)4 */ /* * Used by /susignup to verify that the stduent number and transaction id combo are valid * returns true or false */ function check_su_trans($sid, $transid) { global $just_members; foreach ($just_members as $member) { if ($sid == $member["card_number"] && $transid == $member["transaction_id"]) { return true; } } return false; } /* * Used to verify taht a given stduent number has paid for membership via the su system. * returns false or true */ function check_su_sid($sid) { global $just_members; foreach ($just_members as $member) { if ($sid == $member["card_number"]) { return true; } } return false; } ?>