4.6.x blogapi.module blogapi_blogger_new_post($appkey, $blogid, $username, $password, $content, $publish)
4.7.x blogapi.module blogapi_blogger_new_post($appkey, $blogid, $username, $password, $content, $publish)
5.x blogapi.module blogapi_blogger_new_post($appkey, $blogid, $username, $password, $content, $publish)
6.x blogapi.module blogapi_blogger_new_post($appkey, $blogid, $username, $password, $content, $publish)

Blogging API callback. Inserts a new blog post as a node.

1 call to blogapi_blogger_new_post()
1 string reference to 'blogapi_blogger_new_post'
blogapi_xmlrpc in modules/blogapi/blogapi.module
Implementation of hook_xmlrpc().


modules/blogapi/blogapi.module, line 180
Enable users to post using applications that support XML-RPC blog APIs.


function blogapi_blogger_new_post($appkey, $blogid, $username, $password, $content, $publish) {
  $user = blogapi_validate_user($username, $password);
  if (!$user->uid) {
    return blogapi_error($user);
  if (($error = _blogapi_validate_blogid($blogid)) !== TRUE) {

    // Return an error if not configured type.
    return $error;
  $edit = array();
  $edit['type'] = $blogid;

  // get the node type defaults
  $node_type_default = variable_get('node_options_' . $edit['type'], array(
  $edit['uid'] = $user->uid;
  $edit['name'] = $user->name;
  $edit['promote'] = in_array('promote', $node_type_default);
  $edit['comment'] = variable_get('comment_' . $edit['type'], 2);
  $edit['revision'] = in_array('revision', $node_type_default);
  $edit['format'] = FILTER_FORMAT_DEFAULT;
  $edit['status'] = $publish;

  // check for bloggerAPI vs. metaWeblogAPI
  if (is_array($content)) {
    $edit['title'] = $content['title'];
    $edit['body'] = $content['description'];
    _blogapi_mt_extra($edit, $content);
  else {
    $edit['title'] = blogapi_blogger_title($content);
    $edit['body'] = $content;
  if (!node_access('create', $edit['type'])) {
    return blogapi_error(t('You do not have permission to create this type of post.'));
  if (user_access('administer nodes') && !isset($edit['date'])) {
    $edit['date'] = format_date(time(), 'custom', 'Y-m-d H:i:s O');
  node_invoke_nodeapi($edit, 'blogapi new');
  $valid = blogapi_status_error_check($edit, $publish);
  if ($valid !== TRUE) {
    return $valid;
  if ($errors = form_get_errors()) {
    return blogapi_error(implode("\n", $errors));
  $node = node_submit($edit);
  if ($node->nid) {
    watchdog('content', '@type: added %title using blog API.', array(
      '@type' => $node->type,
      '%title' => $node->title,
    ), WATCHDOG_NOTICE, l(t('view'), "node/{$node-&gt;<span class="php-function-or-constant property member-of-variable">nid</span>}"));

    // blogger.newPost returns a string so we cast the nid to a string by putting it in double quotes:
    return "{$node-&gt;<span class="php-function-or-constant property member-of-variable">nid</span>}";
  return blogapi_error(t('Error storing post.'));