private function __setAttribute($postObj) { if (count($postObj) == 1) { $post = new Application_Model_Facebook_Post(); $post->setOptions(array("postId" => $postObj->post_id, "message" => $postObj->message, "picture" => $postObj->picture, "type" => $postObj->type, "createdTime" => $postObj->created_time, "updatedTime" => $postObj->updated_time)); return $post; } elseif (count($postObj) > 1) { $postList = array(); foreach ($postObj as $row) { $post = new Application_Model_Facebook_Post(); $post->setOptions(array("postId" => $row->post_id, "message" => $row->message, "picture" => $row->picture, "type" => $row->type, "createdTime" => $row->created_time, "updatedTime" => $row->updated_time)); $postList[] = $post; } return $postList; } }
public function questionAction() { /**Note *Test ok */ try { $page_id = $this->_request->getParam('page_id_poll'); $question = $this->_request->getParam('question'); $op1 = $this->_request->getParam('op1'); $op2 = $this->_request->getParam('op2'); $type = "questions"; $data = array('question' => $question, 'options' => array($op1, $op2)); $page_info = Fb_Facebook::api($page_id . "?fields=access_token"); if (!empty($page_info['access_token'])) { $data['access_token'] = $page_info['access_token']; $post = new Application_Model_Facebook_Post(); $question_post = $post->createPost($page_id, $type, $data); if ($question_post) { echo $question_post['id']; exit; } else { echo 'fail'; exit; } } else { echo "empty access token"; } } catch (FacebookApiException $e) { echo $e; exit; } }