How to: Register a work via URL
You can register a work simply providing an URL where the work can be downloaded from.
You must know the file size and its SHA-1 checksum so that Safe Creative can validate that the downloaded file is correct.
Files registered by URL are not immediately registered, but are enqueued for download and remain in PROCESSING state until the work has been successfully downloaded and registered.
Get a nonce key
You need the nonce key before calling work.register. Use authkey.state to get it.
REQUEST:
https://api.safecreative.org/v2/ ?authkey=1i5g2aaf2bz09lyo867cuimqg &component=authkey.state &sharedkey=zy9x4ol0ctg3btyswq7b5wi9 &ztime=1271749860933 &signature=a863a801741d7247482558c9728185b1c09ad8fe
RESPONSE:
<?xml version="1.0" encoding="UTF-8"?> <authkeystate> <authkey>1i5g2aaf2bz09lyo867cuimqg</authkey> <level>MANAGE</level> <noncekey>3z99ur075zdovwlk9osft31i1</noncekey> <usercode>0907100000018</usercode> <authorized>true</authorized> </authkeystate>
Register the work
To register the work you must simply call work.register with the appropiate parameters:
- url: URL address where the work will be downloaded from
- checksum: SHA-1 hash of the work contents
- size: File size in bytes
REQUEST:
https://api.safecreative.org/v2/ ?allowdownload=1 &authkey=1i5g2aaf2bz09lyo867cuimqg &checksum=ffbd10fbce392320e2826f65c4dbe2f8ff05594c &component=work.register &excerpt=Only+for+testing &filename=image.png &license=http%3A%2F%2Fcreativecommons.org%2Flicenses%2Fnc-sampling%2B%2F1.0%2F &noncekey=3z99ur075zdovwlk9osft31i1 &obs=More+info+at+%3Ca+href%3D%27http%3A%2F%2Fsafecreative.info%27%3Ehttp%3A%2F%2Fsafecreative.info%3C%2Fa%3E ®istrypublic=1 &size=28971 &tags=tag1%2C+tag2 &title=My+second+registration &url=http%3A%2F%2Farena.safecreative.org%2Fi18n%2Fdefault%2Fbanner-register.png &usealias=1 &userauthor=1 &worktype=article &ztime=1271749861198 &signature=1e1d60ee9fc90e60eec0cd7b7bb095c4afea9869
RESPONSE:
<?xml version="1.0" encoding="UTF-8"?> <workregistry> <code>1004200146130</code> </workregistry>
Callbacks
As stated above, work will stay in PROCESSING state until correctly downloaded. Your application will be sent a callback when download has been finished or if the work could not be downloaded.
Download successful
If the work could be downloaded, it will pass to PREREGISTERED or REGISTERED state (depending on whether it was registered with parameter final=1 or not).
In that case, your application will receive a workstate callback
{your callback URL} ?component=workstate &ztime=1248523203872 &code=1004200146130 &state=PREREGISTERED &signature=b43f1942381b9ea77449932478e488e4ff43a244
Download failure
If the work could not be downloaded, or its size or checksum do not match those provided on work.register, you will receive a workdownload callback.
{your callback URL} ?component=workdownload &ztime=1248523203872 &code=1004200146130 &url=http%3A%2F%2Farena.safecreative.org%2Fi18n%2Fdefault%2Fbanner-register.png &status=CHECKSUM_MISMATCH &signature=b43f1942381b9ea77449932478e488e4ff43a244