{"id":21959725,"url":"https://github.com/rusticisoftware/scormcloud-api-v2-client-php","last_synced_at":"2025-07-22T12:32:13.548Z","repository":{"id":37444338,"uuid":"177436921","full_name":"RusticiSoftware/scormcloud-api-v2-client-php","owner":"RusticiSoftware","description":"Swagger Generated PHP Client for SCORM Cloud API v2","archived":false,"fork":false,"pushed_at":"2024-02-09T22:15:41.000Z","size":719,"stargazers_count":18,"open_issues_count":0,"forks_count":13,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-31T00:12:56.391Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RusticiSoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-03-24T16:00:54.000Z","updated_at":"2024-05-29T19:37:37.000Z","dependencies_parsed_at":"2023-12-08T21:37:22.647Z","dependency_job_id":null,"html_url":"https://github.com/RusticiSoftware/scormcloud-api-v2-client-php","commit_stats":{"total_commits":15,"total_committers":4,"mean_commits":3.75,"dds":0.6666666666666667,"last_synced_commit":"ba9782384c3e69eef67414048128a296f7653049"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RusticiSoftware%2Fscormcloud-api-v2-client-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RusticiSoftware","download_url":"https://codeload.github.com/RusticiSoftware/scormcloud-api-v2-client-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227089851,"owners_count":17729573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T09:32:12.704Z","updated_at":"2024-11-29T09:32:13.447Z","avatar_url":"https://github.com/RusticiSoftware.png","language":"PHP","readme":"# scormcloud-api-v2-client-php\nREST API used for SCORM Cloud integrations.\n\nThis PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:\n\n- API version: 2.0\n- Package version: 4.0.0\n- Build package: io.swagger.codegen.languages.PhpClientCodegen\n\n## Requirements\nPHP 8.0 and later\n\n## Installation\n### Composer\n[scormcloud-api-v2-client-php](https://packagist.org/packages/rustici-software/scormcloud-api-v2-client-php)\n\n```\ncomposer require rustici-software/scormcloud-api-v2-client-php\n```\n\n## Tips and Tricks\nWorking with headers will require calling the `WithHttpInfo` version of the function. This allows for grabbing the header directly from the response object:\n```php\n// Note: This code is specifically designed to not modify any existing data\n$dispatch_api = new RusticiSoftware\\Cloud\\V2\\Api\\DispatchApi();\n$response = $dispatch_api-\u003eupdateDispatchesWithHttpInfo(new \\RusticiSoftware\\Cloud\\V2\\Model\\UpdateDispatchSchema(), null, new DateTime(\"now\"));\nprint($response[2]['X-Total-Count'][0])\n```\n\n## Changelog\n### Release 2.0.X:\n- Boolean parameters no longer need to be passed as strings to parse correctly.\n- The service class' constructor no longer requires passing of a configuration object. If no config object is passed,\nthe default will automatically be used instead.\n\nCheck the [changelog](https://cloud.scorm.com/docs/v2/reference/changelog/) for further details of what has changed.\n\n## Sample Code\n```php\n\u003c?php\nrequire_once('vendor/autoload.php');\nuse RusticiSoftware\\Cloud\\V2 as ScormCloud;\n\n\n// ScormCloud API credentials\n// Note: These are not the same credentials used to log in to ScormCloud\nconst APP_ID = 'APP_ID';\nconst SECRET_KEY = 'SECRET_KEY';\n\n// Sample values for data\nconst COURSE_PATH = '/PATH/TO/COURSE/RunTimeAdvancedCalls_SCORM20043rdEdition.zip';\n\nconst COURSE_ID = 'PHP_SAMPLE_COURSE';\nconst LEARNER_ID = 'PHP_SAMPLE_COURSE_LEARNER';\nconst REGISTRATION_ID = 'PHP_SAMPLE_COURSE_REGISTRATION';\n\n// String used for output formatting\nconst OUTPUT_BORDER = \"---------------------------------------------------------\\n\";\n\n\n/**\n * This sample will consist of:\n * 1. Creating a course.\n * 2. Registering a learner for the course.\n * 3. Building a link for the learner to take the course.\n * 4. Getting the learner's progress after having taken the course.\n * 5. Viewing all courses and registrations.\n * 6. Deleting all of the data created via this sample.\n *\n * All input variables used in this sample are defined up above.\n */\nfunction main() {\n    // Configure HTTP basic authorization: APP_NORMAL\n    $config = new ScormCloud\\Configuration();\n    $config-\u003esetUsername(APP_ID);\n    $config-\u003esetPassword(SECRET_KEY);\n\n    // Set the default configuration values for new configuration objects\n    ScormCloud\\Configuration::setDefaultConfiguration($config);\n\n    $sc = new ScormCloud_Php_Sample();\n\n    try {\n        // Create a course and a registration\n        $courseDetails = $sc-\u003ecreateCourse(COURSE_ID, COURSE_PATH);\n        $sc-\u003ecreateRegistration(COURSE_ID, LEARNER_ID, REGISTRATION_ID);\n\n        // Show details of the newly imported course\n        echo 'Newly Imported Course Details: ', PHP_EOL;\n        echo $courseDetails, PHP_EOL;\n\n\n\n        // Create the registration launch link\n        $launchLink = $sc-\u003ebuildLaunchLink(REGISTRATION_ID);\n\n        // Show the launch link\n        echo OUTPUT_BORDER, PHP_EOL;\n        echo \"Launch Link: {$launchLink}\", PHP_EOL;\n        echo 'Navigate to the url above to take the course. Hit enter once complete.', PHP_EOL;\n        readline();\n\n\n\n        // Get the results for the registration\n        $registrationProgress = $sc-\u003egetResultForRegistration(REGISTRATION_ID);\n\n        // Show details of the registration progress\n        echo OUTPUT_BORDER, PHP_EOL;\n        echo 'Registration Progess: ', PHP_EOL;\n        echo $registrationProgress, PHP_EOL;\n\n\n\n        // Get information about all the courses in ScormCloud\n        $courseList = $sc-\u003egetAllCourses();\n\n        // Show details of the courses\n        echo OUTPUT_BORDER, PHP_EOL;\n        echo 'Course List: ', PHP_EOL;\n        foreach ($courseList as $course) {\n            echo $course, PHP_EOL;\n        }\n\n\n\n        // Get information about all the registrations in ScormCloud\n        $registrationList = $sc-\u003egetAllRegistrations();\n\n        // Show details of the registrations\n        echo OUTPUT_BORDER, PHP_EOL;\n        echo 'Registration List: ', PHP_EOL;\n        foreach ($registrationList as $registration) {\n            echo $registration, PHP_EOL;\n        }\n    } catch (ScormCloud\\ApiException | InvalidArgumentException $e) {\n        echo $e-\u003egetMessage(), PHP_EOL;\n    } finally {\n        // Delete all the data created by this sample\n        $sc-\u003ecleanUp(COURSE_ID, REGISTRATION_ID);\n    }\n}\n\nclass ScormCloud_Php_Sample {\n\n    /**\n     * Sets the default OAuth token passed with all calls to the API.\n     *\n     * If a token is created with limited scope (i.e. read:registration),\n     * calls that require a different permission set will error. Either a\n     * new token needs to be generated with the correct scope, or the\n     * default access token can be reset to null. This would cause the\n     * request to be made with basic auth credentials (appId/ secret key)\n     * instead.\n     *\n     * Additionally, you could create a new configuration object and set\n     * the token on that object instead of the default access token. This\n     * configuration would then be passed into the Api object:\n     *\n     * $config = new ScormCloud\\Configuration();\n     * $tokenRequest = new ScormCloud\\Model\\TokenRequestSchema([\n     *     'permissions' =\u003e new ScormCloud\\Model\\PermissionsSchema([\n     *         'scopes' =\u003e ['write:course', 'read:course']\n     *     ]),\n     *     'expiry' =\u003e (new DateTime('now'))-\u003emodify('+2 minutes')\n     * ]);\n     * $config-\u003esetAccessToken($applicationManagementApi-\u003ecreateToken($tokenRequest)-\u003egetResult());\n     * $courseApi = new ScormCloud\\Api\\CourseApi(null, $config, null);\n     *\n     * Any calls that would use this CourseApi instance would then have the\n     * write:course and read:course permissions passed automatically, but\n     * other instances would be unaffected and continue to use other means\n     * of authorization.\n     *\n     * @param string[] $scopes List of permissions for calls made with the token.\n     */\n    private function configureOAuth($scopes) {\n        $applicationManagementApi = new ScormCloud\\Api\\ApplicationManagementApi();\n\n        // Set permissions and expiry time of the token\n        $expiry = (new DateTime('now'))-\u003emodify('+2 minutes');\n        $permissions = new ScormCloud\\Model\\PermissionsSchema([ 'scopes' =\u003e $scopes ]);\n\n        // Make the request to get the OAuth token\n        $tokenRequest = new ScormCloud\\Model\\TokenRequestSchema([ 'permissions' =\u003e $permissions, 'expiry' =\u003e $expiry ]);\n        $tokenResult = $applicationManagementApi-\u003ecreateToken($tokenRequest);\n\n        // Set the default access token used with further API requests.\n        // To remove the token, reset the accessToken of\n        // ScormCloud\\Configuration::getDefaultConfiguration()\n        // back to null before the next call.\n        ScormCloud\\Configuration::getDefaultConfiguration()-\u003esetAccessToken($tokenResult-\u003egetResult());\n    }\n\n    /**\n     * Creates a course by uploading the course from your local machine.\n     * Courses are a package of content for a learner to consume.\n     *\n     * Other methods for importing a course exist. Check the documentation\n     * for additional ways of importing a course.\n     *\n     * @param string $courseId   Id that will be used to identify the course.\n     * @param string $coursePath Path to the course being uploaded.\n     * @return ScormCloud\\Model\\CourseSchema Detailed information about the newly uploaded course.\n     */\n    function createCourse($courseId, $coursePath) {\n        // (Optional) Further authenticate via OAuth token access\n        // $this-\u003econfigureOAuth([ 'write:course', 'read:course' ]);\n\n        // This call will use OAuth with the 'write:course' scope\n        // if configured.  Otherwise the basic auth credentials will be used\n        $courseApi = new ScormCloud\\Api\\CourseApi();\n        $jobId = $courseApi-\u003ecreateUploadAndImportCourseJob($courseId, 'false', null, 'application/zip', null, new SplFileObject($coursePath));\n\n        // This call will use OAuth with the 'read:course' scope\n        // if configured.  Otherwise the basic auth credentials will be used\n        $jobResult = $courseApi-\u003egetImportJobStatus($jobId-\u003egetResult());\n        while ($jobResult-\u003egetStatus() == ScormCloud\\Model\\ImportJobResultSchema::STATUS_RUNNING) {\n            sleep(1);\n            $jobResult = $courseApi-\u003egetImportJobStatus($jobId-\u003egetResult());\n        }\n\n        if ($jobResult-\u003egetStatus() == ScormCloud\\Model\\ImportJobResultSchema::STATUS_ERROR)\n            throw new InvalidArgumentException('Course is not properly formatted: ' . $jobResult-\u003egetMessage());\n\n        return $jobResult-\u003egetImportResult()-\u003egetCourse();\n    }\n\n    /**\n     * Creates a registration allowing the learner to consume the course\n     * content. A registration is the link between a learner and a single\n     * course.\n     *\n     * @param string $courseId       Id of the course to register the learner for.\n     * @param string $learnerId      Id that will be used to identify the learner.\n     * @param string $registrationId Id that will be used to identify the registration.\n     */\n    function createRegistration($courseId, $learnerId, $registrationId) {\n        // (Optional) Further authenticate via OAuth token access\n        // $this-\u003econfigureOAuth([ 'write:registration' ]);\n\n        $registrationApi = new ScormCloud\\Api\\RegistrationApi();\n        $learner = new ScormCloud\\Model\\LearnerSchema([ 'id' =\u003e $learnerId ]);\n        $registration = new ScormCloud\\Model\\CreateRegistrationSchema([ 'course_id' =\u003e $courseId, 'learner' =\u003e $learner, 'registration_id' =\u003e $registrationId]);\n        $registrationApi-\u003ecreateRegistration($registration);\n    }\n\n    /**\n     * Builds a url allowing the learner to access the course.\n     *\n     * This sample will build the launch link and print it out. It will then\n     * pause and wait for user input, allowing you to navigate to the course\n     * to generate sample learner progress. Once this step has been reached,\n     * hitting the enter key will continue program execution.\n     *\n     * @param string $registrationId Id of the registration the link is being built for.\n     * @return string Link for the learner to launch the course.\n     */\n    function buildLaunchLink($registrationId) {\n        // (Optional) Further authenticate via OAuth token access\n        // $this-\u003econfigureOAuth([ 'read:registration' ]);\n\n        $registrationApi = new ScormCloud\\Api\\RegistrationApi();\n        $settings = new ScormCloud\\Model\\LaunchLinkRequestSchema([ 'redirect_on_exit_url'  =\u003e 'Message' ]);\n        $launchLink = $registrationApi-\u003ebuildRegistrationLaunchLink($registrationId, $settings);\n\n        return $launchLink-\u003egetLaunchLink();\n    }\n\n    /**\n     * Gets information about the progress of the registration.\n     *\n     * For the most up-to-date results, you should implement our postback\n     * mechanism. The basic premise is that any update to the registration\n     * would cause us to send the updated results to your system.\n     *\n     * More details can be found in the documentation:\n     * https://cloud.scorm.com/docs/v2/guides/postback/\n     *\n     * @param string Id of the registration to get results for.\n     * @return ScormCloud\\Model\\RegistrationSchema Detailed information about the registration's progress.\n     */\n    function getResultForRegistration($registrationId) {\n        // (Optional) Further authenticate via OAuth token access\n        // $this-\u003econfigureOAuth([ 'read:registration' ]);\n\n        $registrationApi = new ScormCloud\\Api\\RegistrationApi();\n        $progress = $registrationApi-\u003egetRegistrationProgress($registrationId);\n\n        return $progress;\n    }\n\n    /**\n     * Gets information about all courses. The result received from the API\n     * call is a paginated list, meaning that additional calls are required\n     * to retrieve all the information from the API. This has already been\n     * accounted for in the sample.\n     *\n     * @return ScormCloud\\Model\\CourseSchema[] List of detailed information about all of the courses.\n     */\n    function getAllCourses() {\n        // (Optional) Further authenticate via OAuth token access\n        // $this-\u003econfigureOAuth([ 'read:course' ]);\n\n        // Additional filters can be provided to this call to get a subset\n        // of all courses.\n        $courseApi = new ScormCloud\\Api\\CourseApi();\n        $response = $courseApi-\u003egetCourses();\n\n        // This call is paginated, with a token provided if more results exist\n        $courseList = $response-\u003egetCourses();\n        while ($response-\u003egetMore() != null) {\n            $response = $courseApi-\u003egetCourses(null, null, 'updated', null, null, 'course_id', 'created_desc', $response-\u003egetMore());\n            $courseList = array_merge($courseList, $response-\u003egetCourses());\n        }\n\n        return $courseList;\n    }\n\n    /**\n     * Gets information about the registration progress for all\n     * registrations. The result received from the API call is a paginated\n     * list, meaning that additional calls are required to retrieve all the\n     * information from the API. This has already been accounted for in the\n     * sample.\n     *\n     * This call can be quite time-consuming and tedious with lots of\n     * registrations. If you find yourself making lots of calls to this\n     * endpoint, it might be worthwhile to look into registration postbacks.\n     *\n     * More details can be found in the documentation:\n     * https://cloud.scorm.com/docs/v2/guides/postback/\n     *\n     * @return ScormCloud\\Model\\RegistrationSchema[] List of detailed information about all of the registrations.\n     */\n    function getAllRegistrations() {\n        // (Optional) Further authenticate via OAuth token access\n        // $this-\u003econfigureOAuth([ 'read:registration' ]);\n\n        // Additional filters can be provided to this call to get a subset\n        // of all registrations.\n        $registrationApi = new ScormCloud\\Api\\RegistrationApi();\n        $response = $registrationApi-\u003egetRegistrations();\n\n        // This call is paginated, with a token provided if more results exist\n        $registrationList = $response-\u003egetRegistrations();\n        while ($response-\u003egetMore() != null) {\n            $response = $registrationApi-\u003egetRegistrations(null, null, null, null, 'created', null, null, 'registration_id', 'created_desc', $response-\u003egetMore());\n            $registrationList = array_merge($registrationList, $response-\u003egetRegistrations());\n        }\n\n        return $registrationList;\n    }\n\n    /**\n     * Deletes all of the data generated by this sample.\n     *\n     * This code is run even if the program has errored out, providing a\n     * \"clean slate\" for every run of this sample.\n     *\n     * It is not necessary to delete registrations if the course\n     * they belong to has been deleted. Deleting the course will\n     * automatically queue deletion of all registrations associated with\n     * the course. There will be a delay between when the course is deleted\n     * and when the registrations for the course have been removed. The\n     * registration deletion has been handled here to prevent scenarios\n     * where the registration hasn't been deleted yet by the time the\n     * sample has been rerun.\n     *\n     * @param string $courseId       Id of the course to delete.\n     * @param string $registrationId Id of the registration to delete.\n     */\n    function cleanUp($courseId, $registrationId) {\n        // (Optional) Further authenticate via OAuth token access\n        // $this-\u003econfigureOAuth([ 'delete:course', 'delete:registration' ]);\n\n        // This call will use OAuth with the 'delete:course' scope\n        // if configured.  Otherwise the basic auth credentials will be used\n        $courseApi = new ScormCloud\\Api\\CourseApi();\n        $courseApi-\u003edeleteCourse($courseId);\n\n        // The code below is to prevent race conditions if the\n        // sample is run in quick successions.\n\n        // This call will use OAuth2 with the 'delete:registration' scope\n        // if configured.  Otherwise the basic auth credentials will be used.\n        $registrationApi = new ScormCloud\\Api\\RegistrationApi();\n        $registrationApi-\u003edeleteRegistration($registrationId);\n    }\n}\n\nmain();\n?\u003e\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusticisoftware%2Fscormcloud-api-v2-client-php/lists"}