src/Util/LTI13.php
public static function loadRoster($membership_url, $access_token, &$debug_log=false) {

        $ch = curl_init();

        $membership_url = trim($membership_url);

        $headers = [
            'Authorization: Bearer '. $access_token,
            'Accept: '.self::MEDIA_TYPE_MEMBERSHIPS,
            'Content-Type: '.self::MEDIA_TYPE_MEMBERSHIPS // TODO: Remove when certification is fixed
        ];

        curl_setopt($ch, CURLOPT_URL, $membership_url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        if ( is_array($debug_log) ) $debug_log[] = $membership_url;
        if ( is_array($debug_log) ) $debug_log[] = $headers;

        $membership = curl_exec($ch);
        $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close ($ch);
        if ( is_array($debug_log) ) $debug_log[] = "Sent roster request, received status=$httpcode (".strlen($membership)." characters)";

        if ( strlen($membership) < 1 ) {
            return "No data retrieved status=" . $httpcode;
        }

        $json = json_decode($membership, false);   // Top level object
        if ( $json === null ) {
            $retval = "Unable to parse returned roster JSON:". json_last_error_msg();
            if ( is_array($debug_log) ) {
                if (is_array($debug_log) ) $debug_log[] = $retval;
                if (is_array($debug_log) ) $debug_log[] = substr($membership, 0, 3000);
            }
            return $retval;
        }

        if ( $httpcode == 200 && isset($json->members) ) {
            if ( is_array($debug_log) ) $debug_log[] = "Loaded ".count($json->members)." roster entries";
            return $json;
        }

        $status = isset($json->error) ? $json->error : "Unable to load results";
        if ( is_array($debug_log) ) $debug_log[] = "Error status: $status";
        return $status;
    }
public static function loadRoster($membership_url, $access_token, &$debug_log=false) {

        $ch = curl_init();

        $membership_url = trim($membership_url);

        $headers = [
            'Authorization: Bearer '. $access_token,
            'Accept: '.self::MEDIA_TYPE_MEMBERSHIPS,
            'Content-Type: '.self::MEDIA_TYPE_MEMBERSHIPS // TODO: Remove when certification is fixed
        ];

        curl_setopt($ch, CURLOPT_URL, $membership_url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        if ( is_array($debug_log) ) $debug_log[] = $membership_url;
        if ( is_array($debug_log) ) $debug_log[] = $headers;

        $membership = curl_exec($ch);
        $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close ($ch);
        if ( is_array($debug_log) ) $debug_log[] = "Sent roster request, received status=$httpcode (".strlen($membership)." characters)";

        if ( strlen($membership) < 1 ) {
            return "No data retrieved status=" . $httpcode;
        }

        $json = json_decode($membership, false);   // Top level object
        if ( $json === null ) {
            $retval = "Unable to parse returned roster JSON:". json_last_error_msg();
            if ( is_array($debug_log) ) {
                if (is_array($debug_log) ) $debug_log[] = $retval;
                if (is_array($debug_log) ) $debug_log[] = substr($membership, 0, 3000);
            }
            return $retval;
        }

        if ( $httpcode == 200 && isset($json->members) ) {
            if ( is_array($debug_log) ) $debug_log[] = "Loaded ".count($json->members)." roster entries";
            return $json;
        }

        $status = isset($json->error) ? $json->error : "Unable to load results";
        if ( is_array($debug_log) ) $debug_log[] = "Error status: $status";
        return $status;
    }
public static function loadRoster ( $ membership_url , $ access_token , & $ debug_log = false ) { $ ch = curl_init ( ) ; $ membership_url = trim ( $ membership_url ) ; $ headers = [ 'Authorization: Bearer ' . $ access_token , 'Accept: ' . self :: MEDIA_TYPE_MEMBERSHIPS , 'Content-Type: ' . self :: MEDIA_TYPE_MEMBERSHIPS // TODO: Remove when certification is fixed ] ; curl_setopt ( $ ch , CURLOPT_URL , $ membership_url ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ headers ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; if ( is_array ( $ debug_log ) ) $ debug_log [ ] = $ membership_url ; if ( is_array ( $ debug_log ) ) $ debug_log [ ] = $ headers ; $ membership = curl_exec ( $ ch ) ; $ httpcode = curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ; curl_close ( $ ch ) ; if ( is_array ( $ debug_log ) ) $ debug_log [ ] = "Sent roster request, received status=$httpcode (" . strlen ( $ membership ) . " characters)" ; if ( strlen ( $ membership ) < 1 ) { return "No data retrieved status=" . $ httpcode ; } $ json = json_decode ( $ membership , false ) ; // Top level object if ( $ json === null ) { $ retval = "Unable to parse returned roster JSON:" . json_last_error_msg ( ) ; if ( is_array ( $ debug_log ) ) { if ( is_array ( $ debug_log ) ) $ debug_log [ ] = $ retval ; if ( is_array ( $ debug_log ) ) $ debug_log [ ] = substr ( $ membership , 0 , 3000 ) ; } return $ retval ; } if ( $ httpcode == 200 && isset ( $ json -> members ) ) { if ( is_array ( $ debug_log ) ) $ debug_log [ ] = "Loaded " . count ( $ json -> members ) . " roster entries" ; return $ json ; } $ status = isset ( $ json -> error ) ? $ json -> error : "Unable to load results" ; if ( is_array ( $ debug_log ) ) $ debug_log [ ] = "Error status: $status" ; return $ status ; }
Call memberships and roles
Call memberships and roles