Search results for 'Metaweblog API'. 3 post(s) found.
- 2008/01/07 How to upload attachments such as image by metaWeblog API ?
- 2008/01/02 How to post blog content by metaweblog API ? (3)
- 2007/12/15 Posting to a Wordpress Blog Via XMLRPC Using Blogger API (1)
How to upload attachments such as image by metaWeblog API ?

Actually this is one of the very important feature to post blog stuffs by Metaweblog API.
Followings are the simple example of posting attachment by Metaweblog API. Actually the unique filename should be passed as third parameter, but the blow sample code automatically extract the file name from the file source.
<?
//requires xmlrpc.inc from http://phpxmlrpc.sourceforge.net/
require_once('xmlrpc.inc');
$g_blog_url = "http://testurl.kurapa.com/api/";
$g_id = "***********";
$g_passwd = "*******";
$GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
function metaWeblog_newMediaObject( $blogid, $file_source, $file_name="")
{
global $g_id;
global $g_passwd;
global $g_blog_url;
// file name extraction from file source in case of having no file name as the third parameter
if ($file_name=="")
{
$p=0;
$file_len = strlen($file_source);
for($i=0; $i<$file_len; $i++)
{
if ($file_source[$i]=='/') $p=$i+1;
}
for( $i=$p; $i<$file_len; $i++) $file_name .= $file_source[$i];
}
// load file content
$fp=fopen($file_source, "rb");
if (!$fp) return null; // file open failure !!
while( !feof($fp))
{
$file_content .= fread( $fp, 1024); // 1024 is the server compatible buffer size
flush();
@ob_flush();
}
fclose($fp);
$client = new xmlrpc_client( "{$g_blog_url}");
$f = new xmlrpcmsg("metaWeblog.newMediaObject", // metaWeblog.newMediaObject Method
array(
new xmlrpcval("{$blogid}", "string"), // blogid.
new xmlrpcval($g_id, "string"), // user ID.
new xmlrpcval($g_passwd, "string"), // password.
new xmlrpcval( // attachment body
array(
'name' => new xmlrpcval($file_name, "base64"),
'bits' => new xmlrpcval($file_content, "base64"),
), "struct")
)
);
$f->request_charset_encoding = 'UTF-8';
$response = $client->send($f);
return $response;
}
Another posts included in "PHP"
| XMLRPC example (0) | 2008/01/07 |
| How to block a connection from the certain site ? (0) | 2008/01/14 |
| File downloading via HTTP (0) | 2008/01/21 |
| How to post blog content by metaweblog API ? (3) | 2008/01/02 |
| Posting to a Wordpress Blog Via XMLRPC Using Blogger API (1) | 2007/12/15 |
| foreach loop (0) | 2007/10/16 |
| Can PHP switch in strings ? (0) | 2007/10/16 |
| PHP Switch Example (0) | 2007/10/16 |
Trackback : Cannot send a trackbact to this post.
-
Subject different money making ideas
2010/01/28 22:58
moneyideas
-
Subject different money making ideas
2010/01/29 07:13
moneyideas
-
Subject different money making ideas
2010/01/31 16:43
moneyideas
"Metaweblog API" is very usefull when you want to post content automatically or periodically. For example, if you are planning to release news letter by collecting the recent articles on your blog, this is very useful tool.
The below module is available with tistory blog. You can also try to other blogs supporting Metaweblog API. As I mentioned in other article, Microsoft Windows Live Writer is also using this kind of technology to post blog stuffs.
In order to post content by Metaweblog API, you need XMLRPC.inc module on the same working directory.
//requires XMLRPC.inc from http://phpXMLRPC.sourceforge.net/
require_once('XMLRPC.inc');
$g_blog_url = "http://demoblog.kurapa.com/api/";
$g_id = "kurapa@kurapa.com";
$g_passwd = "*****";
$GLOBALS['XMLRPC_internalencoding'] = 'UTF-8';
function metaWeblog_newPost( $blogid, $title, $content, $tags, $category="")
{
global $g_id;
global $g_passwd;
global $g_blog_url;
$client = new XMLRPC_client( "{$g_blog_url}");
$f = new XMLRPCmsg("metaWeblog.newPost", // metaWeblog.newPost method
array(
new XMLRPCval("{$blogid}", "string"), // blogid.
new XMLRPCval($g_id, "string"), // user ID.
new XMLRPCval($g_passwd, "string"), // password
new XMLRPCval( // body
array(
'title' => new XMLRPCval($title, "base64"),
'description' => new XMLRPCval($content, "base64"),
'category' => new XMLRPCval($category, "base64"),
'mt_keywords' => new XMLRPCval($tags, "base64")
), "struct"),
new XMLRPCval(true, "boolean") // publish
)
);
$f->request_charset_encoding = 'UTF-8';
$response = $client->send($f);
}
metaWeblog_newPost( 0, "test title", "content should be added here", "tag1,tag2");
?>
Another posts included in "PHP"
| How to upload attachments such as image by metaWeblog API ? (0) | 2008/01/07 |
| XMLRPC example (0) | 2008/01/07 |
| How to block a connection from the certain site ? (0) | 2008/01/14 |
| Posting to a Wordpress Blog Via XMLRPC Using Blogger API (1) | 2007/12/15 |
| foreach loop (0) | 2007/10/16 |
| Can PHP switch in strings ? (0) | 2007/10/16 |
| PHP Switch Example (0) | 2007/10/16 |
| How to send email in PHP ? (0) | 2007/10/16 |
Trackback : Cannot send a trackbact to this post.
-
Subject Russian incest.
2009/02/11 16:52
Incest motherson. Taboo incest forum.
-
Subject Tramadol wikipedia the free encyclopedia.
2009/05/21 07:42
Tramadol. Tramadol cheap no rx free overnight shipping. What is tramadol.
-
Subject Cheap tramadol.
2009/05/22 07:33
Tramadol ultam.
-
Subject Xanax overdose.
2009/05/25 09:22
Xanax 2 mg 180 pills. No rx online xanax.
-
Subject Valium.
2009/06/01 08:58
Valium side effects. Valium 5mg how long in system. Valium no prescription. No prescription valium. What does valium look like. Buy valium online. Valium.
-
Subject Taking valium while breast feeding.
2009/06/17 06:00
Valium no prescription. Buy valium c.o.d.. Lorazepam to valium conversion. What does valium look like. Valium liquid form. Valium dose appropriate. Valium.
-
Subject different money making ideas
2010/01/28 23:46
moneyideas
-
Subject different money making ideas
2010/01/29 08:10
moneyideas
-
Subject different money making ideas
2010/01/31 16:42
moneyideas
RPCXML is now the standard widely using on earth.
Microsoft Windows Live is also using RPCXML in order to post blog content.
Actually there are lots of specification for posting blog stuffs: Metaweblog API, Blogger API, and so on.
Following is the simple example can post blog stuffs directly via your PHP server.
//requires xmlrpc.inc from http://phpXMLRPC.sourceforge.net/
require_once('xmlrpc.inc');
$XMLRPCurl = "http://your blog url/XMLRPC.php";
$client = new XMLRPC_client($XMLRPCurl);
$params[] = new XMLRPCval("n/a");
$params[] = new XMLRPCval("n/a");
$params[] = new XMLRPCval("login"); //your Wordpress login
$params[] = new XMLRPCval("password"); //your Wordpress password
$params[] = new XMLRPCval(
"<title>The Post Title</title>". //the title of your post
"<category>"."[CATEGORY]"."</category>". //the category
$posttext); //the body
$params[] = new XMLRPCval("true"); //publish now = true
$msg = new XMLRPCmsg("blogger.newPost",$params);
$response = $client->send($msg);
?>
Another posts included in "PHP"
| How to post blog content by metaweblog API ? (3) | 2008/01/02 |
| How to upload attachments such as image by metaWeblog API ? (0) | 2008/01/07 |
| XMLRPC example (0) | 2008/01/07 |
| foreach loop (0) | 2007/10/16 |
| Can PHP switch in strings ? (0) | 2007/10/16 |
| PHP Switch Example (0) | 2007/10/16 |
| How to send email in PHP ? (0) | 2007/10/16 |
| How to pass variables via url (0) | 2007/10/16 |
Trackback : Cannot send a trackbact to this post.
-
Subject different money making ideas
2010/01/29 01:17
moneyideas
-
Subject different money making ideas
2010/01/29 09:45
moneyideas
-
Subject different money making ideas
2010/01/31 16:42
moneyideas
Prev

Rss Feed