Last active
May 16, 2017 21:51
-
-
Save zvineyard/0705c56f41e788d06fe1be8c0f70a20e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = 'https://astra.nnu.edu/AstraProd'; | |
$responderUrl = "/~api/calendar/calendarList?action=get"; | |
$responderParameter = 'fields=ActivityID,ActivityName,Description,SectionMeetInstanceByActivityId.SectionMeetingID,EventMeetingByActivityId.EventId,ParentActivityName,StartDate,EndDate,StartMinute,EndMinute,SectionMeetInstanceByActivityId.SectionMeeting.PrimaryInstructor.Person.ContactInformation.Email,SectionMeetInstanceByActivityId.SectionMeeting.PrimaryInstructor.Person.FirstName,SectionMeetInstanceByActivityId.SectionMeeting.PrimaryInstructor.Person.LastName,ActivityTypeCode,Location.Room.Id,BuildingCode,RoomNumber,LocationName,RoomName&filter=((StartDate>%3D"01%2F01%2F2017")%26%26(EndDate<"06%2F01%2F2017")%26%26(ActivityTypeCode=="251"))&sortOrder=StartDate&limit=1000&view=json'; | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_URL, $url . "/Logon.ashx"); | |
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); | |
curl_setopt($curl, CURLOPT_HEADER, FALSE); | |
curl_setopt($curl, CURLOPT_COOKIEJAR, 'tmp_astra_cookie_file.txt'); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, "{'username': 'user', 'password':'pass'}"); | |
if ($result = curl_exec($curl)) { | |
// Success if $result is (bool) true | |
} else { | |
//echo "Ad Astra API login failure.<br>"; | |
exit('Login failed'); | |
} | |
curl_close($curl); | |
// Run another CURL request for the data | |
$request = curl_init(); | |
curl_setopt($request, CURLOPT_URL, $url . $responderUrl); | |
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); | |
curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_setopt($request, CURLOPT_CUSTOMREQUEST, "POST"); | |
curl_setopt($request, CURLOPT_HEADER, FALSE); | |
curl_setopt($request, CURLOPT_COOKIEFILE, 'tmp_astra_cookie_file.txt'); | |
curl_setopt($request, CURLOPT_COOKIEJAR, 'tmp_astra_cookie_file.txt'); | |
curl_setopt($request, CURLOPT_POSTFIELDS, $responderParameter); | |
//die($url . $responderUrl . $responderParameter); | |
$result = curl_exec($request); | |
curl_close($request); | |
if ($result) | |
{ | |
//$data = new SimpleXMLElement($result); | |
print_r($result); | |
die(); | |
/* | |
foreach ($data->Item as $entry) | |
{ | |
echo "XML Activity Name: " . $entry->ActivityName . "<br>"; | |
} | |
*/ | |
} | |
else | |
{ | |
echo "Secondary Request failure.<br>"; | |
exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment