<?php

ini_set("max_execution_time", 30000);
require dirname(__FILE__) . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../Psr4AutoloaderClass.php";
$LRConfig = new LearningRegistry\LearningRegistryConfig(array("url" => "sandbox.learningregistry.org", "username" => "*****@*****.**", "https" => 1, "signing" => 1, "password" => "", "passphrase" => "", "oauthSignature" => "", "auth" => "basic", "keyPath" => "", "publicKeyPath" => ""));
$LR = new LearningRegistry\LearningRegistryServices\LearningRegistryUpdate($LRConfig);
$LRDocument = new LearningRegistry\LearningRegistryDocuments\LearningRegistryReplaceDocument(array("sandbox.learningregistry.org", "8bc07b5153cd4551af8705403b84bdd8", $LR));
$LRDocument->emptyDocument($LR);
$LRDocument->setIdFields(array('curator' => "*****@*****.**", 'owner' => "*****@*****.**", 'signer' => "*****@*****.**", 'submitter_type' => "user", 'submitter' => "*****@*****.**"));
$LRDocument->setSigFields(array('signature' => "", 'key_server' => "", 'key_location' => "", 'key_owner' => "", 'signing_method' => ""));
$LRDocument->setResFields(array('resource_locator' => "www.wibble.com", 'keys' => array("boo", "hoo"), 'resource_data' => htmlspecialchars_decode("DATA!!!!!")));
$LRDocument->setResFields(array('replaces' => array("8bc07b5153cd4551af8705403b84bdd8")));
// Turn the arrays above into a document
$LR->createDocument();
$LR->signDocument();
// Verify the document is ok (optional)
if ($LR->verifyUpdatedDocument()) {
    // make the document into LR format and ready
    $LR->finaliseDocument();
    // send the document
    $LR->UpdateService();
    echo "the response code is " . $LR->getStatusCode() . "<br />";
    echo "the OK is " . $LR->getOK() . "<br />";
    print_r($LR->getResponse());
    if ($LR->getOK() != "1") {
        echo "the Error is " . $LR->getError() . "<br />";
    } else {
        echo "the doc ID is " . $LR->getDocID() . "<br />";
    }
}
Пример #2
0
<?php

require dirname(__FILE__) . "/../vendor/autoload.php";
require dirname(__FILE__) . "/../Psr4AutoloaderClass.php";
$LRConfig = new LearningRegistry\LearningRegistryConfig(array("url" => "sandbox.learningregistry.org", "username" => "*****@*****.**", "https" => 1, "signing" => 1, "password" => "", "oauthSignature" => "", "auth" => "basic", "keyPath" => "", "publicKeyPath" => ""));
// Create a new service (publish means we want to publish)
$LR = new LearningRegistry\LearningRegistryServices\LearningRegistryUpdateRemove($LRConfig);
$LRDocument = new LearningRegistry\LearningRegistryDocuments\LearningRegistryReplaceDocument(array("sandbox.learningregistry.org", "61c31414c7414afc98ecddcb48a0b4d4"));
$LRDocument->emptyDocument($LR);
$LRDocument->newResourceData($LR, htmlspecialchars_decode("I am some data"));
// Turn the arrays above into a document
$LR->createDocument();
// Verify the document is ok (optional)
if ($LR->verifyUpdatedDocument()) {
    // make the document into LR format and ready
    $LR->finaliseDocument();
    // send the document
    $LR->updateRemoveService();
    echo "the response code is " . $LR->getStatusCode() . "<br />";
    echo "the OK is " . $LR->getOK() . "<br />";
    if ($LR->getOK() != "1") {
        echo "the Error is " . $LR->getError() . "<br />";
    } else {
        echo "New ID is " . $LR->getNewID();
    }
}