title: Posting to blogger with PHP
body: <p>I'm getting problem to to get my php script posting to blogger using client http authentication.</p>
  
  <p>I've followed the tutorial from <a href="https://developers.google.com/blogger/docs/1.0/developers_guide_php" rel="nofollow">https://developers.google.com/blogger/docs/1.0/developers_guide_php</a></p>
  
  <p>Here is my code:</p>
  
  <pre><code>require_once 'Zend/Loader.php';
  Zend_Loader::loadClass('Zend_Gdata');
  Zend_Loader::loadClass('Zend_Gdata_Query');
  Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
  
  $user = 'myuserid';
  $pass = 'mypassword';
  $blogUrl = 'myblog.blogspot.com';
  $service = 'blogger';
  
  $gdClient = new Zend_Gdata($client);
  $blogID = getBlogId($gdClient, 'http://'.$blogUrl.'/feeds/posts/default');
  
  $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service, null,
          Zend_Gdata_ClientLogin::DEFAULT_SOURCE, null, null, 
          Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, 'GOOGLE');
  
  function createPublishedPost($gdClient, $myBlogId, $title='Hello, world!', $content='I am blogging on the internet.')
  {
      $uri = 'https://www.blogger.com/feeds/' . $myBlogId . '/posts/default';
      echo $uri; // nothing wrongs here.
      $entry = $gdClient-&gt;newEntry();
      $entry-&gt;title = $gdClient-&gt;newTitle($title);
      $entry-&gt;content = $gdClient-&gt;newContent($content);
      $entry-&gt;content-&gt;setType('text');
  
      $createdPost = $gdClient-&gt;insertEntry($entry, $uri); // I think the error is here.
      $idText = split('-', $createdPost-&gt;id-&gt;text);
      $newPostID = $idText[2];
  
      return $newPostID;
  }
  
  function getBlogId($gdClient, $feed)
  {
      $gdClient = new Zend_Gdata($client);
      $query = new Zend_Gdata_Query($feed);
      $feed = $gdClient-&gt;getFeed($query);
      preg_match('/blog-([0-9]+)/', $feed-&gt;id-&gt;text, $match);
      if (isset($match[1]))
      {
          return $match[1];
      }
      return false;
  }
  
  createPublishedPost($gdClient, $blogID);
  </code></pre>
  
  <p>error message is:</p>
  
  <pre><code>Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 401 User does not have permission to create new post' in /home/content/36/9549036/html/[MYUSER]/Zend/Gdata/App.php:714 Stack trace: #0 /home/content/36/9549036/html/[MYUSER]/Zend/Gdata.php(221): Zend_Gdata_App-&gt;performHttpRequest('POST', 'https://www.blo...', Array, '&lt;atom:entry xml...', 'application/ato...', NULL) #1 /home/content/36/9549036/html/[MYUSER]/Zend/Gdata/App.php(905): Zend_Gdata-&gt;performHttpRequest('POST', 'https://www.blo...', Array, '&lt;atom:entry xml...', 'application/ato...') #2 /home/content/36/9549036/html/[MYUSER]/Zend/Gdata/App.php(980): Zend_Gdata_App-&gt;post(Object(Zend_Gdata_Entry), 'https://www.blo...', NULL, NULL, Array) #3 /home/content/36/9549036/html/[MYUSER]/test.php(29): Zend_Gdata_App-&gt;insertEntry(Object(Zend_Gdata_Entry), 'https://www.blo...') #4 /home/content/36/9549036/html/[MYUSER]/test.php(49): createPublishedPost(Object(Zend_Gdata), '[MYBLOGID]...') #5 {main} thrown in /home/content/36/9549036/html/[MYUSER]/Zend/Gdata/App.php on line 714
  </code></pre>
  
  <p>Has anyone experienced this before?
  Is there any working code out there to post blogger with php?</p>