PHP

How to post blog content by metaweblog API ?

CK CK 3788 
Created at
Updated at  
486 0 0

"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.

 

<?php
//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");

?>


 

Tags Blogger API PHP PHP RPCXML PHP Tistory Posting PHP XMLRPC RPCXML Wordpress get random value by SQL xmlrpc.inc Facebook X
Comments 0
Similar posts
  1. How to upload attachments such as image by metaWeblog API ?
    391
  2. XMLRPC example
    760
  3. How to block a connection from the certain site ?
    350
  4. Posting to a Wordpress Blog Via XMLRPC Using Blogger API
    763
  5. File downloading via HTTP
    445
  6. How to extract file name from given URL ?
    442
  7. How to download a file from a certain URL to server ?
    419
  8. ISO 8601 format time format string conversion
    534
  9. HTML redirection in PHP
    398
  10. Get the actual filesize for a size above 2GB in Windows
    427
  11. How to convert W3C Date Time Format ?
    453
  12. foreach loop
    442
  13. Can PHP switch in strings ?
    391
  14. PHP Switch Example
    427
  15. How to send email in PHP ?
    889
  16. How to pass variables via url
    468
  17. How to declare array in PHP like C/C++
    670
  18. PHP date and time formatting
    428
  19. How to redirect browser in PHP ?
    484
  20. How to get current filename as variable ?
    768
  21. email validation, simple
    412
  22. How to ban / block IP addresses
    509
  23. for loop - simple
    449
  24. form action - detect form post
    428
  25. How to make random number ?
    517
  26. How to force cookies, disable php sessid in URL ?
    555
  27. How to check if a file exists ?
    786
  28. How to include a file with error reporting ?
    428
  29. PHP if...else... example
    445
  30. PHP form handling example in single page
    415
  1. Directory listing in PHP
    511
  2. Seconds to String in PHP
    435
  3. How to delete file on certain path ?
    388
  4. ASCII Artwork Generator from image file
    469
  5. How to limit by Timeout when opening URL ?
    457
  6. How to put timeout when opening URL by fopen ?
    440
  7. How to convert W3C Date Time Format ?
    453
  8. Get the actual filesize for a size above 2GB in Windows
    427
  9. HTML redirection in PHP
    398
  10. ISO 8601 format time format string conversion
    534
  11. How to download a file from a certain URL to server ?
    419
  12. How to extract file name from given URL ?
    442
  13. File downloading via HTTP
    445
  14. XMLRPC example
    760
  15. How to upload attachments such as image by metaWeblog API ?
    391
  16. Posting to a Wordpress Blog Via XMLRPC Using Blogger API
    763
  17. foreach loop
    442
  18. Can PHP switch in strings ?
    391
  19. PHP Switch Example
    427
  20. How to send email in PHP ?
    889
  21. How to pass variables via url
    468
  22. How to declare array in PHP like C/C++
    670
  23. PHP date and time formatting
    428
  24. How to redirect browser in PHP ?
    484
  25. How to get current filename as variable ?
    768
  26. email validation, simple
    412
  27. How to ban / block IP addresses
    509
  28. for loop - simple
    449
  29. form action - detect form post
    428
  30. How to make random number ?
    517
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    27
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    24
  3. How do I create animated background for Google Meet?
    19,728
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    217
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    86
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    153
  7. Array of arguments passed to script in PHP
    85
  8. Invalid Auction Storms in Ad Tech
    93
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    198
  10. The Two Clocks of Ad Server Architecture
    63
  11. Frequency Cap Architecture Overview
    509
  12. Collecting Proof-of-Play from 100,000 Screens
    141
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    280
  14. What is RedisVL?
    105
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    224
  16. TPU & GPU Cluster Management Tools
    234
  17. The Concept of Scaffolding in AI Agents
    222
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    576
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    253
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    328
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    197
  22. Machine Learning: Training vs. Ranking
    213
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    217
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    189
  25. Designing a Data Curation System Around a Vector Database
    215
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    229
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    649
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    185
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    207
  30. Understanding Data Lineage
    252