Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 316089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:21:06+00:00 2026-05-12T08:21:06+00:00

I’m having a problem getting the Blogger API for PHP to work. What I

  • 0

I’m having a problem getting the Blogger API for PHP to work.

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 :
http://code.google.com/intl/nl/apis/blogger/docs/1.0/developers_guide_php.html

Here is my code :

<?
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->newEntry();
  $entry->title = $gdClient->newTitle($title);
  $entry->content = $gdClient->newContent($content);
  $entry->content->setType('text');

  $createdPost = $gdClient->insertEntry($entry, $uri);
  $idText = split('-', $createdPost->id->text);
  $newPostID = $idText[2]; 

  return $newPostID; 
}

createPublishedPost();
?>

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’

Can anyone help me out or give me a working code sample of how to post to blogger using PHP ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:21:06+00:00Added an answer on May 12, 2026 at 8:21 am

    Your $gdClient variable is intanciated outside of the createPublishedPost function :

    $gdClient = new Zend_Gdata($client); 
    

    Inside a function, the variables that have been defined outside of it don’t exist by default.

    About that, you can take a look at the Variable scope page of the manual.

    This means $gdClient doesn’t exist inside the function ; hence, it is null ; so, not an object — which explains the error message you are getting.

    To check that by yourself, you can use

    var_dump($gdClient);
    

    at the beginning of the function : it will allow you to see what kind of data it is ; if it’s not an instance of the class you are willing to use, it’s not a good sign 😉

    You might want to either :

    • pass that variable as a parameter to the createPublishedPost function
    • or declare it as global inside the function (so the function can “see” the variable as declared outside)

    The first solution is probably the cleanest one, I think 😉

    As a sidenote, you might want to configure your error_reporting level (see also), so you get an E_NOTICE when you are using a variable that is not declared — in this case, you should have gotten one, for instance 😉

    You might also want to enable display_errors, on your development machine, if it’s not already on — seems to be, as you got the Fatal error message

    It might seem a bit annoying at the beginning, but, once you get used to it, it is really great : allow to detect that kind of stuff a lot quicker 😉

    And it also helps detect typos in variable names ^^

    And it makes you code way cleaner !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 207k
  • Answers 207k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could use UNION ALL for this: select a, b,… May 12, 2026 at 9:17 pm
  • Editorial Team
    Editorial Team added an answer Seams you don't have proper configuration of maven-eclipse-plugin if you… May 12, 2026 at 9:17 pm
  • Editorial Team
    Editorial Team added an answer The way that I've done this -- you really probably… May 12, 2026 at 9:17 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.