Note that there are some explanatory texts on larger screens.

plurals
  1. POPosting to Blogger using PHP
    text
    copied!<p>I'm having a problem getting the Blogger API for PHP to work.</p> <p>What I need is to be able to post a new blogpost to my bloggeraccount. The code I'm using is taken from the Google API page here : <a href="http://code.google.com/intl/nl/apis/blogger/docs/1.0/developers_guide_php.html" rel="nofollow noreferrer">http://code.google.com/intl/nl/apis/blogger/docs/1.0/developers_guide_php.html</a></p> <p>Here is my code :</p> <pre><code>&lt;? require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_Query'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); $user = 'name@example.com'; $pass = 'password'; $service = 'blogger'; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service, null, Zend_Gdata_ClientLogin::DEFAULT_SOURCE, null, null, Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, 'GOOGLE'); $gdClient = new Zend_Gdata($client); $blogID = '7973737751295446679'; function createPublishedPost($title='Hello, world!', $content='I am blogging on the internet.') { $uri = 'http://www.blogger.com/feeds/' . $blogID . '/posts/default'; $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); $idText = split('-', $createdPost-&gt;id-&gt;text); $newPostID = $idText[2]; return $newPostID; } createPublishedPost(); ?&gt; </code></pre> <p>The error I'm getting is 'Fatal error: Call to a member function newEntry() on a non-object in C:\xampp\htdocs\HelloWorld\blogger2.php on line 21'</p> <p>Can anyone help me out or give me a working code sample of how to post to blogger using PHP ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload