HFP-3048 Add UI for getting content data

+ Update sharing UI
content-hub
Frode Petterson 2020-09-02 16:22:06 +02:00
parent eb52ec25a0
commit 8b317fa5fe
2 changed files with 27 additions and 1 deletions

View File

@ -3712,6 +3712,32 @@ class H5PCore {
);
}
/**
* Publish content on the H5P Hub.
*
* @param bigint $id
* @return stdClass
*/
public function hubRetrieveContent($id) {
$headers = array(
'Authorization' => $this->hubGetAuthorizationHeader(),
'Accept' => 'application/json',
);
$response = $this->h5pF->fetchExternalData(
H5PHubEndpoints::createURL(H5PHubEndpoints::CONTENT . "/{$id}"),
NULL, TRUE, NULL, TRUE, $headers
);
if (empty($response['data'])) {
throw new Exception($this->h5pF->t('Unable to authorize with the H5P Hub. Please check your Hub registration and connection.'));
}
$hub_content = json_decode($response['data'])->data;
$hub_content->id = "$hub_content->id";
return $hub_content;
}
/**
* Publish content on the H5P Hub.
*

File diff suppressed because one or more lines are too long