Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes to instagram client #161

Open
wants to merge 1 commit into
base: contao-4.13
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/EventListener/DataContainer/SocialFeedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ private function requestAccessToken($clientId): void
$this->session->save();

$data = [
'app_id' => $clientId,
'client_id' => $clientId,
'redirect_uri' => $this->router->generate('instagram_auth', [], RouterInterface::ABSOLUTE_URL),
'response_type' => 'code',
'scope' => 'instagram_business_basic',
];

throw new RedirectResponseException('https://api.instagram.com/oauth/authorize/?'.http_build_query($data));
throw new RedirectResponseException('https://www.instagram.com/oauth/authorize/?'.http_build_query($data));
}

/**
Expand Down
16 changes: 8 additions & 8 deletions src/Importer/InstagramClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,27 +206,27 @@ public function getTags(string $accessToken, int $userId = null, bool $cache = t
/**
* Get the access token.
*/
public function getAccessToken(string $appId, string $appSecret, string $code, string $redirectUri): ?array
public function getAccessToken(string $clientId, string $clientSecret, string $code, string $redirectUri): ?array
{
if (($token = $this->getShortLivedAccessToken($appId, $appSecret, $code, $redirectUri)) === null) {
if (($token = $this->getShortLivedAccessToken($clientId, $clientSecret, $code, $redirectUri)) === null) {
return null;
}

return $this->getLongLivedAccessToken($token, $appSecret);
return $this->getLongLivedAccessToken($token, $clientSecret);
}

/**
* Get the short-lived access token.
*
* @return string
*/
private function getShortLivedAccessToken(string $appId, string $appSecret, string $code, string $redirectUri): ?string
private function getShortLivedAccessToken(string $clientId, string $clientSecret, string $code, string $redirectUri): ?string
{
try {
$response = $this->getClient()->post('https://api.instagram.com/oauth/access_token', [
'form_params' => [
'app_id' => $appId,
'app_secret' => $appSecret,
'client_id' => $clientId,
'client_secret' => $clientSecret,
'grant_type' => 'authorization_code',
'redirect_uri' => $redirectUri,
'code' => $code,
Expand Down Expand Up @@ -256,13 +256,13 @@ private function getShortLivedAccessToken(string $appId, string $appSecret, stri
/**
* Get the long-lived access token.
*/
private function getLongLivedAccessToken(string $token, string $appSecret): ?array
private function getLongLivedAccessToken(string $token, string $clientSecret): ?array
{
try {
$response = $this->getClient()->get('https://graph.instagram.com/access_token', [
'query' => [
'grant_type' => 'ig_exchange_token',
'client_secret' => $appSecret,
'client_secret' => $clientSecret,
'access_token' => $token,
],
]);
Expand Down
Loading