title: How to register a new post on blogger using PHP?
body: <pre><code>&lt;?php
      session_start();
  
      require_once dirname(__FILE__) . '/google-api-php-client/src/Google/autoload.php'; // or wherever autoload.php is located
      require_once dirname(__FILE__).'/google-api-php-client/src/Google/Service/Blogger.php';
  
  $scriptUri = "http://".$_SERVER["HTTP_HOST"].$_SERVER['PHP_SELF'];
  
  $client = new Google_Client();
  $client-&gt;setAccessType('online'); // default: offline
  $client-&gt;setApplicationName('Title'); //name of the application
  $client-&gt;setClientId('xxxxxxxxxxx.apps.googleusercontent.com'); //insert your client id
  $client-&gt;setClientSecret('zzzzzzzzzzzzzzzzzzz'); //insert your client secret
  $client-&gt;setRedirectUri($scriptUri); //redirects to same url
  $client-&gt;setDeveloperKey('yyyyyyyyyyyyyyyyy'); // API key (at bottom of page)
  $client-&gt;setScopes(array('https://www.googleapis.com/auth/blogger')); //since we are going to use blogger services
  
  
  $blogger = new Google_Service_Blogger($client);  
  
  if (isset($_GET['logout'])) { // logout: destroy token
      unset($_SESSION['token']);
   die('Logged out.');
  }
  
  if (isset($_GET['code'])) { // we received the positive auth callback, get the token and store it in session
      $client-&gt;authenticate();
      $_SESSION['token'] = $client-&gt;getAccessToken();
  }
  
  if (isset($_SESSION['token'])) { // extract token from session and configure client
      $token = $_SESSION['token'];
      $client-&gt;setAccessToken($token);
  }
  
  if (!$client-&gt;getAccessToken()) { // auth call to google
      $authUrl = $client-&gt;createAuthUrl();
      header("Location: ".$authUrl);
      die;
  }
  //you can get the data about the blog by getByUrl
  $data = $blogger-&gt;blogs-&gt;getByUrl(array('url'=&gt;'http://gggggggggg.blogspot.com/'));
  
  //creates a post object
  $mypost = new Google_Service_Blogger_Post();
  $mypost-&gt;setTitle('this is a test 1 title');
  $mypost-&gt;setContent('this is a test 1 content');
  $data = $blogger-&gt;posts-&gt;insert('999999999999999', $mypost);
  ?&gt;
  </code></pre>
  
  <p>Is returning the error:
  Warning: Missing argument 1 for Google_Client::authenticate(), called in /home/vvvvvvvvvv/public_html/post2.php on line 27 and defined in /home/vvvvvvvvvv/public_html/google-api-php-client/src/Google/Client.php on line 122</p>
  
  <p>Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Invalid code' in /home/vvvvvvvvvv/public_html/google-api-php-client/src/Google/Auth/OAuth2.php:87 Stack trace: #0 /home/vvvvvvvvv/public_html/google-api-php-client/src/Google/Client.php(125): Google_Auth_OAuth2->authenticate(NULL) #1 /home/vvvvvvvvvv/public_html/post2.php(27): Google_Client->authenticate() #2 {main} thrown in /home/vvvvvvvvvv/public_html/google-api-php-client/src/Google/Auth/OAuth2.php on line 87</p>