/** * Posts a new notice using the register feed. This function constructs * the atom profile entry. * * @param string $subject The subject line of the notice * @param string $body The message body of the notice * @param string $bodyType The (optional) type of message body * (text, xhtml, html, etc.) * @param string $ccrXML The (optional) CCR to add to the user's profile * @return Zend_Gdata_Health_ProfileEntry */ public function sendHealthNotice($subject, $body, $bodyType = null, $ccrXML = null) { if ($this->_httpClient->getClientLoginToken()) { $profileID = $this->getProfileID(); if ($profileID !== null) { $uri = self::CLIENTLOGIN_REGISTER_FEED_URI . '/' . $profileID; } else { require_once 'Zend/Gdata/App/AuthException.php'; throw new Zend_Gdata_App_AuthException('Profile ID must not be null. Did you call setProfileID()?'); } } else { $uri = self::AUTHSUB_REGISTER_FEED_URI; } $entry = new Zend_Gdata_Health_ProfileEntry(); $entry->title = $this->newTitle($subject); $entry->content = $this->newContent($body); $entry->content->type = $bodyType ? $bodyType : 'text'; $entry->setCcr($ccrXML); // use correct feed for /h9 or /health if ($this->_useH9Sandbox) { $uri = preg_replace('/\\/health\\//', '/h9/', $uri); } return $this->insertEntry($entry, $uri, 'Zend_Gdata_Health_ProfileEntry'); }
public function testSendNoticeWithoutCcrUsingDirectInsert() { $this->setupProfileID(); $profileID = $this->health->getProfileID(); $subject = "Title of your notice goes here"; $body = "Notice body goes here"; $entry = new Zend_Gdata_Health_ProfileEntry(); $author = $this->health->newAuthor(); $author->name = $this->health->newName('John Doe'); $author->email = $this->health->newEmail('*****@*****.**'); $entry->setAuthor(array(0 => $author)); $entry->title = $this->health->newTitle($subject); $entry->content = $this->health->newContent($body); $entry->content->type = 'text'; $ccrXML = file_get_contents('Zend/Gdata/Health/_files/ccr_notice_sample.xml', true); $entry->setCcr($ccrXML); $uri = "https://www.google.com/health/feeds/register/ui/{$profileID}"; $responseEntry = $this->health->insertEntry($entry, $uri, 'Zend_Gdata_Health_ProfileEntry'); $this->assertTrue($responseEntry instanceof Zend_Gdata_Health_ProfileEntry); $this->assertEquals($subject, $responseEntry->title->text); $this->assertEquals($author->name->text, 'John Doe'); $this->assertEquals($author->email->text, '*****@*****.**'); $this->assertEquals($body, $responseEntry->content->text); }