Clone wiki

restclient-php / Basic Requests

Requests and Models

The most API requests need a couple of parameters that specify what exactly the API should do.

GET Requests

An example: If you like to get posts you have to determine which kind of resources you want to get: Bookmarks (URLs) or Bibtex (publications). Also, you have to deliver the owner (e. g. user or group) from whose collection you want to get that posts.


use AcademicPuma\RestClient\Config;

$posts = $restClient->getPosts(Config\Resourcetype::BOOKMARK, Config\Grouping::USER, "some_username")->model();

// Get the title of the first received bookmark:
$bookmarkTitle = $posts[0]->getResource()->getTitle();


PUT Requests

In order to update a concept transmit a model object to the method and the name of the user who is holding the concept. The model object needs the name of the concept you want to update.


use AcademicPuma\RestClient\Model;

// Create a concept Model-Object:
$subTag = new Model\Tag();

$tag = new Model\Tag();

$restClient->updateConcept($tag, "UserName");


POST Requests

In most cases you're going to create posts directly. Posts already containing users, visibility groups and tags, so you don't need to create those separatly.

Have a look at the following example:


use AcademicPuma\RestClient\Model;
$userName = '' // define Post owner's userName

// initialize user
$user = new Model\User();

// initialize tag
$tag = new Model\Tag();

// initialize visibility group.
$group = new Model\Group();

// initialize bookmark.
$bookmark = new Model\Bookmark();
$bookmark->setTitle('REST Client Repository');

// initialize post
$post = new Model\Post();
$post->setDescription('Sources of the restclient-php library');

// submit the request
$restClient->createPosts($post, $userName);

Similarly, you can create Concepts, UserRelationships and Documents.

If you want to attach a Document to an existing Publication Post, try the following:

$filePath = '/full/path/to/File.pdf';
$restClient->createDocument($filePath, $post->getResource()->getIntraHash(), $post->getUser()->getName());

DELETE Request

You want to delete something? No problem:


$fileName = $somePost->getDocuments()[0]->getFilename();
$resourceHash = $somePost->getResource()->getIntrahash();

$restClient->deleteDocument("MyUserName", $resourceHash, $fileName);