Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

Represent the url for each method and the encoding of the parameters and response. The code is based on badges/classes/backpack_api_mapping.php by Yuliya Bozhko <yuliya.bozhko@totaralms.com>.

Author: Tung Thai <Tung.ThaiDuc@nashtechglobal.com>
Copyright: 2020 Tung Thai
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 178 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

backpack_api2p1_mapping:: (5 methods):
  __construct()
  is_match()
  get_url()
  get_curl_options()
  request()


Class: backpack_api2p1_mapping  - X-Ref

Represent a single method for the remote api and this class using for Open Badge API v2.1 methods.

__construct($action, $url, $postparams,$multiple, $method, $json, $authrequired, $isuserbackpack, $backpackapiversion)   X-Ref
Create a mapping.

param: string $action The action of this method.
param: string $url The base url of this backpack.
param: mixed $postparams List of parameters for this method.
param: boolean $multiple This method returns an array of responses.
param: string $method get or post methods.
param: boolean $json json decode the response.
param: boolean $authrequired Authentication is required for this request.
param: boolean $isuserbackpack user backpack or a site backpack.
param: integer $backpackapiversion OpenBadges version 1 or 2.

is_match($action)   X-Ref
Does the action match this mapping?

param: string $action The action.
return: boolean

get_url($apiurl)   X-Ref
Parse the method url and insert parameters.

param: string $apiurl The raw apiurl.
return: string

get_curl_options()   X-Ref
Standard options used for all curl requests.

return: array

request($apiurl, $tokenkey, $post = [])   X-Ref
Make an api request and parse the response.

param: string $apiurl Raw request url.
param: string $tokenkey to verify authorization.
param: array $post request method.
return: bool|mixed