»Twitter/Identi.ca compatible gNewBook API

 ·API Root
 ·Autentication
 ·Available methods
 ·Current Applications

ATwitter/Identi.ca compatible gNewBook API

 

API root

The API root for gNewBook is http://www.gnewbook.org/api/. However, there is no resource at the API root (Just shows the home page).
To make API calls you tack on the method name. Examples: :
- http://www.gnewbook.org/api/public_timeline.php
- http://www.gnewbook.org/api/user_timeline.php
- http://www.gnewbook.org/api/friends_timeline.php

Specifying format:

- http://www.gnewbook.org/api/xml/public_timeline.php
- http://www.gnewbook.org/api/json/public_timeline.php
- http://www.gnewbook.org/api/xml/user_timeline.php
- http://www.gnewbook.org/api/xml/friends_timeline.php

(Top)

 

Authentication

Like Twitter and Identi.ca, the gNewBook API uses HTTP Basic Authentication. However before using the API, is recommendable publish a post using the Web Site.
There's no support for other, undocumented authentication methods.

(Top)

 

Available Methods

Public Timeline
http://www.gnewbook.org/api/public_timeline.php
Get latest publications for public access (XML y JSON).

User Timeline
http://www.gnewbook.org/api/user_timeline.php
Get latest publications for authenticated user.

Friends Timeline
http://www.gnewbook.org/api/friends_timeline.php
Get latest publications from friends of authenticated user.

Update
http://www.gnewbook.org/api/update.php
Publish your updates, like others requires authentication.

(Top)

 

Current Applications

Any client that support Twitter/Identi.ca compatible APIs under HTTP Basic Authentication must work.
Next you could find a list of tested applications for gNewBook API.

- Java Swing Client for gNewBook

This is simple java client for desktop enviroment. Source code for NetBeans project structure is available too from here.

- IdenTickles tcl/tk

Our dear friend and gNewBooker Tony Baldwin develop a very potent client for integrate gNewBook using his API Rest under Tcl/Tk, this client include install scripts for GNU/Linux and Windows.

Finally, here you can get some examples writen on Bash and PHP.

- Example using Curl under Bash

#!/bin/bash
USERNAME=""
PASSWORD=""
URL=http://www.gnewbook.org/api/update.php
RST=$(curl -s -u $USERNAME:$PASSWORD -d status="$1" $URL > /tmp/gNewBook_up2date.log)
IDS=$(cat /tmp/gNewBook_up2date.log | grep "</id>" | head -n1 | cut -d '>' -f2 | cut -d '<' -f1)
echo "Posted on gNewBook whit ID:"$IDS
exit 0

- PHP Example

<?php
$username = 'yourusername';
$password = 'yourpassword';
$message  = 'Sent from PHP to gNewBook';
$url = 'http://www.gnewbook.org/api/update.php';
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "$url");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (empty($buffer)) {
    echo 'message';
} else {
    echo 'success';
}
?>

If you develop a new client and want be listed here, please contact us.

(Top)