From b59f28d39828fa6ce78e9aef34be2ce60642250d Mon Sep 17 00:00:00 2001 From: Rhys Lees <43909932+RhysLees@users.noreply.github.com> Date: Fri, 31 Jan 2025 14:56:34 +0000 Subject: [PATCH 1/5] WIP --- .../GetInstagramBusinessDiscoveryMedia.php | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 src/Requests/GetInstagramBusinessDiscoveryMedia.php diff --git a/src/Requests/GetInstagramBusinessDiscoveryMedia.php b/src/Requests/GetInstagramBusinessDiscoveryMedia.php new file mode 100755 index 0000000..dc39621 --- /dev/null +++ b/src/Requests/GetInstagramBusinessDiscoveryMedia.php @@ -0,0 +1,88 @@ +user_id; + + if (empty($user_id)) { + $user_id = InstagramHandler::user()->user_id; + } + + return $user_id; + } + + public function defaultQuery(): array + { + $fields = collect([ + 'followers_count', + 'media_count', + ]); + + $mediaFields = collect([ + 'id', + 'caption', + 'media_type', + 'media_url', + 'permalink', + 'thumbnail_url', + 'timestamp', + 'username', + ]); + + $childFields = collect([ + 'id', + 'media_type', + 'media_url', + 'permalink', + 'timestamp', + 'username', + ]); + + if ($this->withChildren) { + $mediaFields->add('children{'.$childFields->join(',').'}'); + } + + $fields->add('media{'.$mediaFields->join(',').'}'); + + return [ + 'fields' => sprintf( + 'business_discovery.username(%s){%s}', + $this->username, + $fields->join(',') + ), + ]; + } + + public function createDtoFromResponse(Response $response): mixed + { + return $response->json(); +// return CreateMediaCollectionFromResponse::fromResponse($response); + } +} From 84d7d2fb49b271e41d9b28ed63669ef606b9acee Mon Sep 17 00:00:00 2001 From: RhysLees <43909932+RhysLees@users.noreply.github.com> Date: Fri, 31 Jan 2025 14:56:55 +0000 Subject: [PATCH 2/5] Fix styling --- src/Requests/GetInstagramBusinessDiscoveryMedia.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Requests/GetInstagramBusinessDiscoveryMedia.php b/src/Requests/GetInstagramBusinessDiscoveryMedia.php index dc39621..87053f0 100755 --- a/src/Requests/GetInstagramBusinessDiscoveryMedia.php +++ b/src/Requests/GetInstagramBusinessDiscoveryMedia.php @@ -6,7 +6,6 @@ use CodebarAg\LaravelInstagram\Actions\InstagramHandler; use CodebarAg\LaravelInstagram\Responses\CreateMediaCollectionFromResponse; -use Illuminate\Support\Collection; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; @@ -83,6 +82,6 @@ public function defaultQuery(): array public function createDtoFromResponse(Response $response): mixed { return $response->json(); -// return CreateMediaCollectionFromResponse::fromResponse($response); + // return CreateMediaCollectionFromResponse::fromResponse($response); } } From 47872924bc558ae7cbd1ae23237b6dc100f60aa0 Mon Sep 17 00:00:00 2001 From: Rhys Lees <43909932+RhysLees@users.noreply.github.com> Date: Wed, 5 Feb 2025 11:25:57 +0000 Subject: [PATCH 3/5] WIP --- .../GetInstagramBusinessDiscoveryMedia.php | 87 ------------------- 1 file changed, 87 deletions(-) delete mode 100755 src/Requests/GetInstagramBusinessDiscoveryMedia.php diff --git a/src/Requests/GetInstagramBusinessDiscoveryMedia.php b/src/Requests/GetInstagramBusinessDiscoveryMedia.php deleted file mode 100755 index 87053f0..0000000 --- a/src/Requests/GetInstagramBusinessDiscoveryMedia.php +++ /dev/null @@ -1,87 +0,0 @@ -user_id; - - if (empty($user_id)) { - $user_id = InstagramHandler::user()->user_id; - } - - return $user_id; - } - - public function defaultQuery(): array - { - $fields = collect([ - 'followers_count', - 'media_count', - ]); - - $mediaFields = collect([ - 'id', - 'caption', - 'media_type', - 'media_url', - 'permalink', - 'thumbnail_url', - 'timestamp', - 'username', - ]); - - $childFields = collect([ - 'id', - 'media_type', - 'media_url', - 'permalink', - 'timestamp', - 'username', - ]); - - if ($this->withChildren) { - $mediaFields->add('children{'.$childFields->join(',').'}'); - } - - $fields->add('media{'.$mediaFields->join(',').'}'); - - return [ - 'fields' => sprintf( - 'business_discovery.username(%s){%s}', - $this->username, - $fields->join(',') - ), - ]; - } - - public function createDtoFromResponse(Response $response): mixed - { - return $response->json(); - // return CreateMediaCollectionFromResponse::fromResponse($response); - } -} From 01ec84c2377b3b284a18dce6a644527efae38816 Mon Sep 17 00:00:00 2001 From: Rhys Lees <43909932+RhysLees@users.noreply.github.com> Date: Wed, 5 Feb 2025 13:09:09 +0000 Subject: [PATCH 4/5] WIP --- README.md | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index cd52040..7529ecb 100755 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ This package is only designed to login with a single user account to display ins * [Navigation](#navigation) * [🛠 Requirements](#-requirements) * [Installation](#installation) + * [Overriding the default routes](#overriding-the-default-routes) * [Usage](#usage) * [Authentication](#authentication) * [Getting the connector](#getting-the-connector) @@ -89,6 +90,25 @@ INSTAGRAM_CLIENT_ID=your-client-id INSTAGRAM_CLIENT_SECRET=your-client-secret ``` +## Creating a new Instagram App + +To create a new Instagram App, you need to register your app on the [Facebook Developer Portal https://developers.facebook.com/apps/](https://developers.facebook.com/apps/) + +When asked for a use case select `Other` +When asked for an app type select `Business` + +Once the app is created you need to add Instagram as a product to your app, you can do this by clicking on the `Add Product` button and selecting Instagram on the left side of the app dashboard. + +Then goto `API setup with Instagram Login`, goto `Step 3.` and click `Business login settings`. + +You will need to set the redirect uri to: `http://your-app-url.com/instagram/callback` + +You should also set the Deauthorize callback URL to: `http://your-app-url.com/instagram/deauthorize` + +You should also set the Deletion callback URL to: `http://your-app-url.com/instagram/delete` + +> NOTE: The links above need to be publicly accessible so you can use tools like NGROK or Expose to expose your local development environment to the internet. When using the tools, ensure you set your `APP_URL` in your `.env` file to the url provided by the tool. + ## Overriding the default routes If you want to override the default routes, you can do so by creating a `instagram.php` file in your routes directory and adding the following code: @@ -111,7 +131,6 @@ Then you should register the routes in your `bootstrap\app.php`: ```php ->withRouting( web: __DIR__ . '/../routes/web.php', - // api: __DIR__ . '/../routes/api.php', then: function () { Route::middleware('web')->group(base_path('routes/instagram.php')); }, @@ -127,17 +146,6 @@ $this->routes(function () { }); ``` -You can get your client id and client secret by registering your app on the [Instagram Developer Portal](https://developers.facebook.com/docs/instagram-platform/instagram-api-with-instagram-login) - -When configuring your app on the Instagram Developer Portal, you will need to set the redirect uri to: `http://your-app-url.com/instagram/callback` - -You should also set the Deauthorize callback URL to: `http://your-app-url.com/instagram/deauthorize` - -You should also set the Deletion callback URL to: `http://your-app-url.com/instagram/delete` - -The links above need to be publicly accessible. You can use tools like [Expose](https://expose.dev/) or [ngrok](https://ngrok.com/) to expose your local development environment to the internet. -When using the tools above, ensure you set your `APP_URL` in your `.env` file to the url provided by the tool. - ## Usage ### Authentication From 142d1d0af4d2b56daddcf5131c35eaf377bf228c Mon Sep 17 00:00:00 2001 From: Rhys Lees <43909932+RhysLees@users.noreply.github.com> Date: Wed, 5 Feb 2025 13:10:05 +0000 Subject: [PATCH 5/5] WIP --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7529ecb..ac8aa94 100755 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ This package is only designed to login with a single user account to display ins * [Navigation](#navigation) * [🛠 Requirements](#-requirements) * [Installation](#installation) + * [Creating a new Instagram App](#creating-a-new-instagram-app) * [Overriding the default routes](#overriding-the-default-routes) * [Usage](#usage) * [Authentication](#authentication)