/** * Inspect the received access token * * @param string $tokenToInspect * @return array * @throws OAuth2Exception */ public function validateSecureRequestCapability($accessToken) { $this->instagramApiClient->setCurrentAccessToken($accessToken); $responseData = $this->instagramApiClient->getOwnUserData(); // at least ID and Username are mandatory if (!isset($responseData['id']) || !isset($responseData['username'])) { return FALSE; } return $responseData; }
/** * Returns the UserData of the currently logged in user or null if none is logged in * also sets the access token in this process if there is one available and it is not set yet * @return array */ public function getUserData() { $userData = NULL; $instagramAccountWithParty = $this->getInstagramAccountHavingParty(); if ($instagramAccountWithParty !== NULL) { $instagramAccessToken = $this->getInstagramAccountHavingParty()->getCredentialsSource(); if ($instagramAccessToken !== NULL) { $this->instagramApiClient->setCurrentAccessToken($instagramAccessToken); $userData = $this->instagramApiClient->getOwnUserData(); } } return $userData; }
/** * Searches instagram for images with a specific tag and returns the given number of results, * paging can be achieved by providing the first or last image of the last used batch of images * * @param string $searchTerm * @param int $count * @param string $max_tag_id * @return array */ public function searchByTagAction($searchTerm, $count = 10, $max_tag_id = null) { $userData = $this->authenticationFlow->getUserData(); $imageset = $this->instagramApiClient->searchByTag($searchTerm, $count, $max_tag_id); $this->view->assign('value', $imageset); }