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

        $lineitem_url = trim($lineitem_url);

        $ch = curl_init();

        $headers = [
            'Authorization: Bearer '. $access_token
        ];

        curl_setopt($ch, CURLOPT_URL, $lineitem_url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");

        if (is_array($debug_log) ) $debug_log[] = 'Line Item URL: '.$lineitem_url;
        if (is_array($debug_log) ) $debug_log[] = $headers;

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

        if ( $httpcode == 200 ) {
            if ( is_array($debug_log) ) $debug_log[] = "Deleted lineitem";
            return true;
        }

        if ( strlen($response) < 1 ) {
            return "Failed with no response body and code=".$httpcode;
        }

        $json = json_decode($response, false);
        if ( $json === null ) {
            $retval = "Unable to parse returned lineitem 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($lineitem, 0, 1000);
            }
            return $retval;
        }

        $status = U::get($json, "error", "Unable to delete lineitem");
        if ( is_array($debug_log) ) $debug_log[] = "Error status: $status";
        return $status;
    }
public static function deleteLineItem($lineitem_url, $access_token, &$debug_log=false) {

        $lineitem_url = trim($lineitem_url);

        $ch = curl_init();

        $headers = [
            'Authorization: Bearer '. $access_token
        ];

        curl_setopt($ch, CURLOPT_URL, $lineitem_url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");

        if (is_array($debug_log) ) $debug_log[] = 'Line Item URL: '.$lineitem_url;
        if (is_array($debug_log) ) $debug_log[] = $headers;

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

        if ( $httpcode == 200 ) {
            if ( is_array($debug_log) ) $debug_log[] = "Deleted lineitem";
            return true;
        }

        if ( strlen($response) < 1 ) {
            return "Failed with no response body and code=".$httpcode;
        }

        $json = json_decode($response, false);
        if ( $json === null ) {
            $retval = "Unable to parse returned lineitem 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($lineitem, 0, 1000);
            }
            return $retval;
        }

        $status = U::get($json, "error", "Unable to delete lineitem");
        if ( is_array($debug_log) ) $debug_log[] = "Error status: $status";
        return $status;
    }
public static function deleteLineItem ( $ lineitem_url , $ access_token , & $ debug_log = false ) { $ lineitem_url = trim ( $ lineitem_url ) ; $ ch = curl_init ( ) ; $ headers = [ 'Authorization: Bearer ' . $ access_token ] ; curl_setopt ( $ ch , CURLOPT_URL , $ lineitem_url ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ headers ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , "DELETE" ) ; if ( is_array ( $ debug_log ) ) $ debug_log [ ] = 'Line Item URL: ' . $ lineitem_url ; if ( is_array ( $ debug_log ) ) $ debug_log [ ] = $ headers ; $ response = curl_exec ( $ ch ) ; $ httpcode = curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ; curl_close ( $ ch ) ; if ( is_array ( $ debug_log ) ) $ debug_log [ ] = "Sent lineitem delete, received status=$httpcode (" . strlen ( $ response ) . " characters)" ; if ( $ httpcode == 200 ) { if ( is_array ( $ debug_log ) ) $ debug_log [ ] = "Deleted lineitem" ; return true ; } if ( strlen ( $ response ) < 1 ) { return "Failed with no response body and code=" . $ httpcode ; } $ json = json_decode ( $ response , false ) ; if ( $ json === null ) { $ retval = "Unable to parse returned lineitem 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 ( $ lineitem , 0 , 1000 ) ; } return $ retval ; } $ status = U :: get ( $ json , "error" , "Unable to delete lineitem" ) ; if ( is_array ( $ debug_log ) ) $ debug_log [ ] = "Error status: $status" ; return $ status ; }
Delete A LineItem
Delete A LineItem