<?php

//This work is licenced under http://creativecommons.org/licenses/GPL/2.0/
include 'Zooomr.php';
function get_user_input($a_message)
{
    print $a_message . "\n";
    $stdin = fopen('php://stdin', 'r');
    $input = fgets($stdin);
    return $input;
}
$zooomr = new ZooomrRestAPI('API_KEY', 'SHARED_SECRET');
$token = 'TOKEN_STRING';
$frob = $zooomr->auth->getFrob();
# check to see if we need to get authorisation
$response = $zooomr->auth->checkToken(array('auth_token' => $token));
#response = false
print "response ";
print_r($response);
if (0 == strcasecmp("fail", $response->json_response->stat)) {
    $link_hash = $zooomr->authenticate_application(array('perms' => "write"));
    print_r($link_hash);
    get_user_input("Follow this to authenticate: " . $link_hash['link']);
    $info_hash = $zooomr->complete_authentication(array('frob' => $link_hash['frob']));
} else {
    $json_resp = $response->json_response;
    $token = $json_resp->auth->_content->token;
    $user = $json_resp->auth->_content->user;
    $user_id = $user->nsid;
    $username = $user->username;
    $fullname = $user->fullname;
 function params_are_valid($a_array_of_required_params = array(), $a_array_of_extra_allowed_param_names = array(), $a_hash_of_params_and_values = array())
 {
     ZooomrRestAPI::params_are_valid($a_array_of_required_params, $a_array_of_extra_allowed_param_names, $a_hash_of_params_and_values);
 }