Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Addons

Post Reply
 
Thread Tools
  #1  
Old 09-14-2008, 09:02 PM
darragh Offline
forum loafer
 
Join Date: Sep 2008
Posts: 2
BloggerAPI Support

Hi,

I am currently writing some BloggerAPI support for PixelPost.
It won't be pretty but it should function with blogging from Flickr.

Hopefully, it should be ready in a few days after I get some issues remedied from Flickr

Darragh
Reply With Quote
  #2  
Old 11-04-2008, 02:20 PM
darragh Offline
forum loafer
 
Join Date: Sep 2008
Posts: 2
Well, this as far as I got before I got distracted into other things.
I'll try getting back to it soon
Darragh

PHP Code:
<?php


/*
* First, we define some PHP functions to expose via
* XML-RPC. Any functions that will be called by a
* XML-RPC client need to take three parameters:
* The first parameter passed is the name of the
* XML-RPC method called, the second is an array
* Containing the parameters sent by the client, and
* The third is any data sent in the app_data
* parameter of the xmlrpc_server_call_method()
* function (see below).
*/

$_debugLog fopen('xmlrpc.log''a');

function 
newPost($method_name$params$app_date) {
        
$appkey $params[0];
        
$blogid $params[1];
        
$username $params[2];
        
$password md5($params[3]);
        
$content $params[4];
        
$publish $params[5];

        
$sql "select id from pixelpost_config where admin='" $username "' AND password='" $password "';";
        if (
mysql_connect($pixelpost_db_host$pixelpost_db_user$pixelpost_db_pass) && mysql_select_db($pixelpost_db_pixelpost)) {

                if (
$cfgquery mysql_query($sql)) {
                        
$heading "";
                        
$body "";
                        
$image "";
                        
$category "";
                        
$alt_headline "";
                        
$alt_body "";
                        
$comments "";
                        
$exif_info "";
                        
$date "";

                        include(
"includes/functions_exif.php");
                        
$exif_info serialize_exif($image);
                        
$sql "INSERT INTO pixelpost_pixelpost (datetime, headline, body, image," .
                        
" category, alt_headline, alt_body, comments, exif_info) " .
                        
" VALUES (" $date ", '" $heading "', '" $body "'," .
                        
" '" $image "', '" $category "', '" $alt_headline "', '" $alt_body "', " .
                        
"'" $comments "', '" $exif_info "');";
                        if (
mysql_query($sql)) {
                                
$sql "select id from pixelpost_pixelpost where datetime=" $date ";";
                                
$cfgquery mysql_query($sql);
                                
$cfgrow mysql_fetch_assoc($cfgquery);
                                
$id $cfgrow['id'];
                                return 
"" $id;
                        }
                } else {
                        
trigger_error("Failed to authenicate");
                }
        }

        return 
"Not currently implemented";
}

function 
editPost($method_name$params$app_date) {
        
$appkey $params[0];
        
$postid $params[1];
        
$username $params[2];
        
$password md5($params[3]);
        
$content $params[4];
        
$publish $params[5];

        return 
"Not currently implemented";
}

function 
getUsersBlogs($method_name$params$app_date) {
        include (
"includes/pixelpost.php");

        
$appkey $params[0];
        
$username $params[1];
        
$password md5($params[2]);
        
$sql "select id, siteurl, sitetitle from pixelpost_config where admin='" $username "' AND password='" $password "';";

        if (
mysql_connect($pixelpost_db_host$pixelpost_db_user$pixelpost_db_pass) && mysql_select_db($pixelpost_db_pixelpost)) {

                if (
$cfgquery mysql_query($sql)) {
                        
$cfgrow mysql_fetch_assoc($cfgquery);
                        
$blogid $cfgrow['id'];
                        
$blogName $cfgrow['sitetitle'];
                        
$url $cfgrow['siteurl'];
                        
$response = array (
                                
"url" => $url,
                                
"blogid" => $blogid,
                                
"blogName" => $blogName
                        
);
                        return 
$response;

                } else {
                        
trigger_error("xmlrpc: Query failed");
                }

        }

        
trigger_error("xmlrpc: Failed to connect to database");

}

function 
getUserInfo($method_name$params$app_date) {
        include (
"includes/pixelpost.php");
        
$appkey $params[0];
        
$username $params[1];
        
$password md5($params[2]);
        
$sql "select id, siteurl, email from " $pixelpost_db_prefix "config where admin='" $username "' AND password='" $password "';";
        if (
mysql_connect($pixelpost_db_host$pixelpost_db_user$pixelpost_db_pass) && mysql_select_db($pixelpost_db_pixelpost)) {

                if (
$cfgquery mysql_query($sql)) {

                        
$cfgrow mysql_fetch_assoc($cfgquery);

                        
$userid $cfgrow['id'];
                        
$email $cfgrow['email'];
                        
$url $cfgrow['siteurl'];
                        
$response = array (
                                
"url" => $url,
                                
"userid" => $userid,
                                
"email" => $email
                        
);
                        return 
$response;
                } else {
                        
trigger_error("xmlrpc : Query failed: " $sql "\n");
                }
        } else {
                
trigger_error("xmlrpc : Could not connect to database");
        }

}

function 
getTemplate($method_name$params$app_date) {
        
$appkey $params[0];
        
$blogid $params[1];
        
$username $params[2];
        
$password $params[3];
        
$templateType $params[4];
        return 
"Not currently implemented";
}

function 
setTemplate($method_name$params$app_date) {
        
$appkey $params[0];
        
$blogid $params[1];
        
$username $params[2];
        
$password $params[3];
        
$template $params[4];
        
$templateType $params[5];
        return 
"Not currently implemented";
}

/*
* This creates a server and sets a handle for the
* server in the variable $xmlrpc_server
*/
$xmlrpc_server xmlrpc_server_create();
/*
* xmlrpc_server_register_method() registers a PHP
* function as an XML-RPC method. It takes three
* parameters:
* The first is the handle of a server created with
* xmlrpc_server_create(), the second is the name to
* register the server under (this is what needs to
* be in the <methodName> of a request for this
* method), and the third is the name of the PHP
* function to register.
*/
xmlrpc_server_register_method($xmlrpc_server"greeting""greeting_func");
xmlrpc_server_register_method($xmlrpc_server"uptime""uptime_func");

xmlrpc_server_register_method($xmlrpc_server"blogger.newPost""newPost");
xmlrpc_server_register_method($xmlrpc_server"blogger.editPost""editPost");
xmlrpc_server_register_method($xmlrpc_server"blogger.getUsersBlogs""getUsersBlogs");
xmlrpc_server_register_method($xmlrpc_server"blogger.getUserInfo""getUserInfo");
xmlrpc_server_register_method($xmlrpc_server"blogger.getTemplate""getTemplate");
xmlrpc_server_register_method($xmlrpc_server"blogger.setTemplate""setTemplate");

/*
* When an XML-RPC request is sent to this script, it
* can be found in the raw post data.
*/
fwrite($_debugLog"RAW_DATA:");
$request_xml $HTTP_RAW_POST_DATA;
fwrite($_debugLog$request_xml "\n");
/*
* The xmlrpc_server_call_method() sends a request to
* the server and returns the response XML. In this case,
* it sends the raw post data we got before. It requires
* 3 arguments:
* The first is the handle of a server created with
* xmlrpc_server_create(), the second is a string containing
* an XML-RPC request, and the third is for application data.
* Whatever is passed into the third parameter of this function
* is passed as the third paramater of the PHP function that the
* request is asking for.
*/
$response xmlrpc_server_call_method($xmlrpc_server$request_xml'');
$response str_replace("iso-8859-1""UTF-8"$response);

// Now we print the response for the client to read.
//$response = str_replace( "<string>", "", $response);
//$response = str_replace( "</string>\n", "", $response);
//$response = str_replace( "<int>", "", $response);
//$response = str_replace( "</int>\n", "", $response);
fwrite($_debugLog"RESPONSE: " $response "\n");
print 
$response;
/*
* This method frees the resources for the server specified
* It takes one argument, a handle of a server created with
* xmlrpc_server_create().
*/
xmlrpc_server_destroy($xmlrpc_server);
?>
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 09:50 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs