<?php
// -------------------------
// Publr API Example - JSON 
// -------------------------

// Set request options
$config['email'] = 'email@domain.com';
$config['password'] = 'password';
$config['start'] = 0;
$config['limit'] = 20;
// options: text, photo, link, video, audio, chat, quote
// if left blank, all post types will be returned
$config['type'] = '';

// Build the query
$request http_build_query(
    array(
        
'email' => $config['email'],
        
'password' => $config['password'],
        
'start' => $config['start'],
        
'limit' => $config['limit'],
        
'type' => $config['type']
    )
);

// Send post request
$c curl_init('http://publr.com/api/json');
curl_setopt($cCURLOPT_POSTtrue);
curl_setopt($cCURLOPT_POSTFIELDS$request);
curl_setopt($cCURLOPT_RETURNTRANSFERtrue);
$response curl_exec($c);
$status curl_getinfo($cCURLINFO_HTTP_CODE);
curl_close($c);

// Did it work?
if($status == 201)
{
    print(
$response);

elseif(
$status == 403)
{
    echo 
'Access denied.';

elseif(
$status == 404)
{
    echo 
"No posts found.";
}
else
{
    echo 
"Error.";
}
?>