Platform Integration

Forums: 

Hi,

I am experimenting with doing a platform integration for H5P in Java and so far so good, I got basic functionality for viewing and editing H5P content.

But currently I am working on the endpoints for the hub and I am struggling a bit with the updateContentTypeCache stuff. The registering with h5p works fine, but when sending a request to http://api.h5p.org/v1/content-types/ like in the php implementations I am getting a 404 status code.

Does somebody know what I am missing here?

At least to me it looks like that is where the request is being sent in the php implementations, it should be a post request with the uuid and other things as a json object right? I feel like there is something bein added to the url somewhere but I am currently not finding it

 

Thank you in advance and best regards

Yannick

thomasmars's picture

Hi,
Are you generating the UUID yourself ? Make sure that it is not longer than 36characters, as that is a limitation forced at the endpoint.
You should really not be generating the UUID yourself, you should send the first request to the "api.h5p.org/v1/sites" endpoint without any UUID, then you will get a unique UUID back, which you'll register for the site.
If it is still not working after this please show us an example of a post request that gets 404'd.

The only thing that is really required for the endpoint to get the content-types is the UUID. However you can add the following additional data to track for your site:

  • platform_name
  • platform_version
  • h5p_version
  • disabled (whether automatic fetching of libraries from h5p.org is disabled for this site)
  • local_id (distinguishes between multiple servers at the same address)
  • type (type of site: internet, network, local)
  • core_api_version

You should be able to find this data in one of the already implemented platforms

I'm really excited about your integration and hope you'll succeed, please keep us updated on your progress :)

Best regards, Thomas

Thanks for the answer the request to "api.h5p.org/v1/sites" works fine and I am getting the a uuid.

My problem is the request to "api.h5p.org/v1/content-types/" which should be a post request with the uuid in a json object as payload right?

I am trying to implement it the same way as it is in the wordpress implementation:

$data = $interface->fetchExternalData(H5PHubEndpoints::createURL(H5PHubEndpoints::CONTENT_TYPES), $postData);

in updateContentTypeCache in h5p.classes.php.

My implementation gives me a 404. I tried http and https and trailing / no trailing slash.

As I said I think I am missing something, sadly I currently can't debug the wordpress implementation but I hope you can help.

thomasmars's picture

Hi, sorry for the slow answer. The post should be a form, with uuid, not a json object.
The following will work for instance:

POST /v1/content-types/ HTTP/1.1
Host: api.h5p.org
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache

uuid=example0-1234-5678-9012-example01234

Hi, thats it thank you very much :)

I was looking int the wrong place, don't know why I thought it should be json

castelmager's picture

Hi,

Are you plannig to share the java integration ? If so we will be very happy :D

Hi

I can't make any promises but the integration will be released at some point in the future ^^

Don't expect it this year though...

Hi,

I have two smaller issues:

1. There is a double slash in a url generated in the frontend which works for current implementations but causes me some problems and is not intended I guess. I've created a github issue: https://github.com/h5p/h5p-editor-php-library/issues/55 but I am not sure if you are using those anymore because you have Jira right?

2. I have a problem with the translation files for the editor. I am trying to add them to the javascript of the json returned by getLibraryData (like here https://github.com/h5p/h5p-editor-php-library/blob/fd8e125eefe95d88edc30...). But the problem is that this results in problems with subcontent (specifically I think the scripts are not loaded). I've gotten the latest wordpress plugin from git and installed it and it seems to have the same problem for languages that are not the default. I made a screenshot for the editor trying to edit IteractiveVideo in wordpress:

editor bug

I think it has something to do with how the scripts are loaded in the frontend: https://github.com/h5p/h5p-editor-php-library/blob/fd8e125eefe95d88edc30... .

 

Best regards

Yannick

thomasmars's picture

Hi,
1) We're still using and checking github, but they're converted into JIRA issues so we'll be able to prioritize them and so that the community can follow the progress on issues that they want solved. I have created a JIRA issue from the github issue where you can follow along the progress: https://h5ptechnology.atlassian.net/browse/HFP-2146

2) It seems like you're using the 'master' branch. You should use the 'stable' branch from github if you're going to use it in production, there are no guarantees on where the 'master' branch is, since it is our active development branch. Currently the 'master' branch requires some new versions of certain libraries, among them the Interactive Video library. Furthermore could you check your console for any errors when this happens ?

Best regards, Thomas

Ah thank you very much for adding the issue.

 

Regarding the second issue: you are also absolutely right I shoud use the stable version as my reference.

There is no error in the console when this happens. I debugged the thing a bit myself before and the problem seems to be that the way scripts for subcontent are loaded was changed. So in getLibraryData the scriptPaths and the content of the scripts have been added to the libraryData.javascript. Now only the paths are added and libraryData.javascript is an array and it is iterated in the frontend with forEach. Which works fine with the default language because no extra translation scripts are added to the array.

If language scripts are added now they still are added to a field named the hash of the script and value the content of the script. This results in libraryData.javascript not being a javascript array anymore and forEach can't be used / just doesn't do anything. So in this case neither the scripts nor the language scripts (translations) are loaded.

 

Best regards

Yannick

icc's picture

Thank you for point out the issue but I think fnoks has already made a fix for it.

Very nice, thank you :)

Hi

I would like to know what is the status of the H5P Java platform integration. We are looking for options to integrate the power of H5P to view and edit H5P content in our Java/Angular app.

Looking forward to any update on the project.