Post

1 follower Follow
0
Avatar

setting up API authorisation

Hi IVe been trying to set up API USername and password authorisation using the following script.

 

<html>

<head>

<title>Username and Password authentication example</title>

</head>

<body>

<?php

// Include the config file and the Podio library

require_once 'config.php';

require_once 'PodioAPI.php';

echo CLIENT_ID;

echo CLIENT_SECRET;

echo USERNAME;

echo PASSWORD;

// Setup the API client reference. Client ID and Client Secrets are defined

// as constants in config.php

Podio::setup(CLIENT_ID, CLIENT_SECRET);

// Use Podio::is_authenticated() to check is there's already an active session.

// If there is you can make API calls right away.

if (!Podio::is_authenticated()) {

// Authenticate using your username and password. Both are defined as constants

// in config.php

Podio::authenticate('password', array('username' => USERNAME, 'password' => PASSWORD));

print "You have been authenticated. Wee!<br>";

$access_token = Podio::$oauth->access_token;

print "Your access token is {$access_token}<br><br>";

print "The access token is automatically saved in a session for your convenience.<br><br>";

}

else {

print "You were already authenticated and no authentication happened. Close and reopen your browser to start over.<br><br>";

}

// Now you can start making API calls. E.g. get your user status

$status = PodioUserStatus::get();

print "Your user id is <b>{$status->user->id}</b> and you have <b>{$status->inbox_new}</b> unread messages in your inbox.<br><br>";

?>

</body>

</html>

 

Please note i added the following code to check my config file was working

echo CLIENT_ID;

echo CLIENT_SECRET;

echo USERNAME;

echo PASSWORD;

However when loading my page i get the following error:

Fatal error: Class 'Podio' not found in /home/youthoas/public_html/podio/index.php on line 19

Line 19 is this code: Podio::setup(CLIENT_ID, CLIENT_SECRET);

Any ideas why this isnt working? 

Joshua Baker

Please sign in to leave a comment.

1 comment