/**
  * Get last user conversations
  *
  * @return array|bool
  */
 public function last()
 {
     $data = Request::createRequestData();
     $query = UrlHelper::buildRequestString($data);
     $response = $this->request->exec(UrlHelper::RESOURCE_GET_LAST_CONVERSATIONS . '?' . $query);
     return $this->response->getData($response);
 }
Esempio n. 2
0
 /**
  * Executes request to Pinterest API
  *
  * @param string $resourceUrl
  * @param string $postString
  * @return array
  */
 public function exec($resourceUrl, $postString = "")
 {
     $url = UrlHelper::buildApiUrl($resourceUrl);
     $this->makeHttpOptions($postString);
     $res = $this->http->init($url)->setOptions($this->options)->execute();
     $this->http->close();
     return json_decode($res, true);
 }
Esempio n. 3
0
 /**
  * @param array $data
  * @param string $url
  * @param string $sourceUrl
  * @param array $bookmarks
  * @return array
  */
 public function getData($data, $url, $sourceUrl, $bookmarks = [])
 {
     $data['options'] = $data;
     $get = Request::createRequestData($data, $sourceUrl, $bookmarks);
     $getString = UrlHelper::buildRequestString($get);
     $response = $this->getRequest()->exec($url . '?' . $getString);
     return $this->getResponse()->getPaginationData($response);
 }
Esempio n. 4
0
 /**
  * Executes search to API. Query - search string.
  *
  * @param string $query
  * @param string $scope
  * @param array  $bookmarks
  * @return array
  */
 public function searchCall($query, $scope, $bookmarks = [])
 {
     $url = UrlHelper::getSearchUrl(!empty($bookmarks));
     $get = $this->createSearchRequest($query, $scope, $bookmarks);
     $url = $url . '?' . UrlHelper::buildRequestString($get);
     $response = $this->getRequest()->exec($url);
     return $this->getResponse()->parseSearchResponse($response, !empty($bookmarks));
 }
Esempio n. 5
0
 /**
  * Get all logged-in user boards
  *
  * @return array|null
  */
 public function my()
 {
     $this->request->checkLoggedIn();
     $get = BoardHelper::createBoardsInfoRequest();
     $getString = UrlHelper::buildRequestString($get);
     $res = $this->request->exec(UrlHelper::RESOURCE_GET_BOARDS . "?{$getString}");
     return BoardHelper::parseBoardsInfoResponse($res);
 }
Esempio n. 6
0
 /**
  * Get user's latest news array
  *
  * @return array
  */
 public function latest()
 {
     $data = ["options" => ['allow_state' => true]];
     $request = Request::createRequestData($data);
     $getString = UrlHelper::buildRequestString($request);
     $response = $this->request->exec(UrlHelper::RESOURCE_GET_LATEST_NEWS . "?{$getString}");
     return $this->response->getData($response);
 }
Esempio n. 7
0
 /**
  * Run GET api request to boards resource
  * @param array  $query
  * @param string $url
  * @param bool   $pagination
  * @return array|bool
  */
 protected function boardsGetCall($query, $url, $pagination = false)
 {
     $getString = UrlHelper::buildRequestString($query);
     $response = $this->request->exec($url . "?{$getString}");
     if ($pagination) {
         return $this->response->getPaginationData($response);
     }
     return $this->response->getData($response);
 }
Esempio n. 8
0
 /**
  * Executes a POST request to Pinterest API
  *
  * @param array  $requestOptions
  * @param string $resourceUrl
  * @param bool   $returnData
  * @return mixed
  */
 public function callPostRequest($requestOptions, $resourceUrl, $returnData = null)
 {
     $data = array("options" => $requestOptions);
     $request = Request::createRequestData($data);
     $postString = UrlHelper::buildRequestString($request);
     $response = $this->request->exec($resourceUrl, $postString);
     if ($returnData) {
         return $this->response->getData($response);
     }
     return $this->response->checkResponse($response);
 }
 /**
  * Send message to a user
  *
  * @param $userId
  * @param $text
  *
  * @return bool
  */
 public function sendMessage($userId, $text)
 {
     $this->request->checkLoggedIn();
     $data = array("options" => array("user_ids" => array($userId), "emails" => array(), "text" => $text), "context" => new \stdClass());
     $dataJson = json_encode($data);
     $post = array('data' => $dataJson);
     $postString = UrlHelper::buildRequestString($post);
     $res = $this->request->exec(UrlHelper::RESOURCE_SEND_MESSAGE, $postString);
     if ($res === null || !isset($res['resource_response']) || $res['resource_response']['error'] !== null) {
         return false;
     }
     return true;
 }
Esempio n. 10
0
 /**
  * Login as pinner
  *
  * @param string $username
  * @param string $password
  * @return bool
  * @throws AuthException
  */
 public function login($username, $password)
 {
     if ($this->request->isLoggedIn()) {
         return true;
     }
     $this->checkCredentials($username, $password);
     $post = PinnerHelper::createLoginRequest($username, $password);
     $postString = UrlHelper::buildRequestString($post);
     $this->request->clearToken();
     $response = $this->request->exec(UrlHelper::RESOURCE_LOGIN, $postString);
     $result = $this->response->checkErrorInResponse($response);
     if (!$result) {
         throw new AuthException($this->response->getLastError()['message']);
     }
     $this->request->setLoggedIn();
     return $result;
 }
Esempio n. 11
0
 /**
  * Get information of pin by PinID
  *
  * @param $pinId
  * @return array|null
  */
 public function info($pinId)
 {
     $get = PinHelper::createInfoRequest($pinId);
     $url = UrlHelper::RESOURCE_PIN_INFO . '?' . UrlHelper::buildRequestString($get);
     $res = $this->request->exec($url);
     return PinHelper::parsePinInfoResponse($res);
 }
Esempio n. 12
0
 /**
  * Get information of a pin by PinID
  *
  * @param int $pinId
  * @return array|bool
  */
 public function info($pinId)
 {
     $requestOptions = ["field_set_key" => "detailed", "id" => $pinId, "pin_id" => $pinId, "allow_stale" => true];
     $data = array("options" => $requestOptions);
     $request = Request::createRequestData($data);
     $url = UrlHelper::RESOURCE_PIN_INFO . '?' . UrlHelper::buildRequestString($request);
     $response = $this->request->exec($url);
     return $this->response->checkResponse($response);
 }
Esempio n. 13
0
 /**
  * Login as pinner
  *
  * @param $username
  * @param $password
  * @return bool
  */
 public function login($username, $password)
 {
     if ($this->request->isLoggedIn()) {
         return true;
     }
     $post = PinnerHelper::createLoginRequest($username, $password);
     $postString = UrlHelper::buildRequestString($post);
     $this->request->clearToken();
     $result = $this->response->checkErrorInResponse($this->request->exec(UrlHelper::RESOURCE_LOGIN, $postString));
     if ($result) {
         $this->request->setLoggedIn();
     }
     return $result;
 }