/**
  * Injects the information of a given poll.
  *
  * @param Poll $poll
  * @return array
  */
 public function injectInfo(Poll $poll)
 {
     $info = $poll->_getInfo();
     if ($info === null) {
         $info = $this->client->_getInfo($poll);
         $poll->_setInfo($info);
     }
     return $info;
 }
示例#2
0
 /**
  * Returns information about a given poll.
  *
  * @param Poll $poll
  * @return array
  * @internal
  */
 public function _getInfo(Poll $poll)
 {
     $data = array('adminKey' => '', 'locale' => $this->locale, 'token' => $this->token);
     $response = $this->doGet('/poll/' . $poll->getId(), $data);
     $info = array();
     if (($pos = strpos($response, '$.extend(true, doodleJS.data, {"poll"')) !== false) {
         $json = substr($response, $pos + 30);
         $json = trim(substr($json, 0, strpos($json, 'doodleJS.data.poll.keywordsJson')));
         // Remove the end of the javascript code
         $json = rtrim($json, ');');
         $info = json_decode($json, true);
     }
     $info = !empty($info['poll']) ? $info['poll'] : array();
     return $info;
 }