private function post($title, $content, $labels, $link) { try { $mypost = new \Google_Service_Blogger_Post(); $mypost->setTitle($title); $mypost->setContent($content); $mypost->setLabels($labels); for ($i = 0; $i < 2; $i++) { try { $article = $this->service->posts->insert($this->blogid, $mypost); break; } catch (\Exception $e) { if ($e->getCode() == 500) { sleep(1); continue; } throw $e; } } $postdata = array(); if (is_object($article)) { $postdata['id'] = $article->getId(); $postdata['title'] = $article->getTitle(); $postdata['selfLink'] = $link; $postdata['url'] = $article->getUrl(); $postdata['labels'] = $article->getLabels(); $postdata['published'] = $article->getPublished(); } return $postdata; } catch (\Exception $e) { $m = 'Cannot post to blogger because ' . $e->getCode() . ' ' . $e->getMessage(); $this->logger->logError($m); } }