Monday, August 10, 2009

publish post on movable type api blog with xmlrpc

Contact Us

Hire PHP Web Developer

require_once('IXR_Library.inc.php'); // Download

$blog_id = "2"; // only blogid no need to set username/password for blog

$admin_user = "username here"; // Login username => that you use at http://www.yourdomain.com/cgi-bin/mt.cgi
$admin_pass = "password here"; // Web Services Password => will be found at http://www.yourdomain.com/cgi-bin/mt.cgi?__mode=view&_type=author&id=XX
$xmlrpc_host = "http://www.yourdomain.com/cgi-bin/mt-xmlrpc.cgi"; // or http://www.yourdomain.com/cgi-bin/mt/mt-xmlrpc.cgi

$client = new IXR_Client($blog_url);

if (!$client->query('metaWeblog.getCategories',$blog_id, $admin_user,$admin_pass)) {
die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
}

$content['title'] = "Free PHP Script";
$content['categories'] = array($response[0]['categoryName']);
$content['description'] = '<p> <b> Free PHP Script !!! </b> <br> Author : Vasim Padhiyar <br> Contact : iamvasim@gmail.com <br> Blog : http://scriptforphp.blogspot.com </p>';

if (!$client->query('metaWeblog.newPost',$blog_id, $admin_user,$admin_pass, $content, true)) {
die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
}
else
{
$response = $client->getResponse();
}

$post_id = $response['postid'];
$post_url = $response['link'];
$category = $response['categories'][0];

Tuesday, August 4, 2009

how to integrate google search api for php

Contact Us

Hire PHP Web Developer

$url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=~car~insurance&rsz=large&hl=en&safe=off";

// sendRequest
// note how referer is set manually
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://www.scriptforphp.blogspot.com");
$body = curl_exec($ch);
curl_close($ch);


// download json library file from Download Here

include('JSON/JSON.php');
$object = new Services_JSON();
$json = $object->decode($body);

echo '<pre>';
print_r($json);
exit;