createAuthor() 공개 메소드

createAuthor
public createAuthor ( $name = null )
예제 #1
0
<pre>
<?php 
// Include the Class
include 'etherpad-lite-client.php';
// Create an instance
$instance = new EtherpadLiteClient('EtherpadFTW', 'http://beta.etherpad.org:9001/api');
// Example URL:  http://your.hostname.tld:8080/api
// All API calls return a JSON value as documented in the API here: https://github.com/Pita/etherpad-lite/wiki/HTTP-API
echo "<h1>Pads</h1>";
/* Example: Create Author */
try {
    $author = $instance->createAuthor('John McLear');
    // This really needs explaining..
    $authorID = $author->authorID;
    echo "The AuthorID is now {$authorID}\n\n";
} catch (Exception $e) {
    // the pad already exists or something else went wrong
    echo "\n\ncreateAuthor Failed with message " . $e->getMessage();
}
/* Example: get Mapped Author ID based on a value from your web application such as the userID */
try {
    $authormap = $instance->createAuthorIfNotExistsFor('John McLear', 'Cake');
    // This would show my local UserID mapping John McLear as Cake on Etherpad
} catch (Exception $e) {
    echo "\n\ncreateAuthorIfNotExistsFor Failed with message " . $e->getMessage();
}
//cake
/* Example: Create a new Pad */
try {
    $instance->createPad('testPad', 'Hello world');
} catch (Exception $e) {