Download the PHP package lemaur/laravel-pinterest-api without Composer
On this page you can find all versions of the php package lemaur/laravel-pinterest-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-pinterest-api
Laravel Pinterest Api
An Object-Oriented wrapper for consuming Pinterest API with Laravel.
It uses Pinterest API v5.
Warning: This package DOESN'T store Pinterest's credentials, you should provide your own logic!
👉 Please read carefully the Manage credentials section! 👈
Support Me
Hey folks,
Do you like this package? Do you find it useful, and it fits well in your project?
I am glad to help you, and I would be so grateful if you considered supporting my work.
You can even choose 😃:
- You can sponsor me 😎 with a monthly subscription.
- You can buy me a coffee ☕ or a pizza 🍕 just for this package.
- You can plant trees 🌴. By using this link we will both receive 30 trees for free and the planet (and me) will thank you.
- You can "Star ⭐" this repository (it's free 😉).
Roadmap
This package still in development.
You can vote for endpoints not yet covered by requesting them here.
If so, it would be great if you wanted sponsor me to support my work.
- [ ] Pins
- [ ] list
- [x] create
- [ ] get
- [x] delete
- [x] update
- [ ] save
- [ ] analytics
- [ ] Boards
- [x] list
- [ ] create
- [ ] get
- [ ] delete
- [ ] update
- [ ] pins
- [ ] Board Sections
- [ ] Ad Accounts
- [ ] Ad Groups
- [ ] Ads
- [ ] Audience Insights
- [ ] Audiences
- [ ] Bulk
- [ ] Campaigns
- [ ] Catalogs
- [ ] Conversion Events
- [ ] Conversion Tags
- [ ] Customer Lists
- [ ] Integrations
- [ ] Interests
- [ ] Keywords
- [ ] Media
- [x] OAuth
- [ ] Order Lines
- [ ] Product Group Promotions
- [ ] Product Groups
- [ ] Resources
- [ ] Search
- [ ] Terms
- [ ] Terms of Service
- [ ] User Account
Installation
You can require the package via composer:
You can install it with:
Manage credentials
Pinterest API Authentication follows the OAuth2 standard.
The package contains helpful methods to obtain the credentials from Pinterest OAuth server, but where to store them is up to you! Every project is different, with different requirements. You can store credentials on disk, or you can write them on DB and so on...
Note: You'll need to register a new app on Pinterest and get the app ID and secret key.
But don't worry, we'll do it in the next section.
Here I'll show you how to configure your project to manage credentials.
The authentication flow returns an object containing access_token
and refresh_token
within the expiration timestamps and other information.
Here an example:
The package emits Lemaur\Pinterest\Events\CredentialsRetrieved::class
event within Lemaur\Pinterest\Data\OAuthData
object when it receives the credentials.
You can listen for this event in your project and store the credentials where you want.
To do that, you need to create a new listener
And inside the handle
method you can decide where to store the credentials.
Don't forget to register the listener in the App\Providers\EventServiceProvider
.
Now it's time to edit the service provider.
Open App\Providers\PinterestServiceProvider
, and inside the register
method you will find a predefined implementation.
As you can see in the @TODO
comment, here is where you should pass the credentials you previously stored.
In the previous examples we stored the credentials in the user's table.
So here, we can fetch them from the authenticated user.
Require Pinterest Access
Register and get your app ID and secret key
Note: internally
app ID
isclient_id
, internallysecret key
isclient_secret
!
- Log into www.pinterest.com; open a new tab with the account that you’ll use to manage your apps.
- Go to My Apps.
- Select Connect app and complete the request form with your app information.
- Submit your request to get trial access.
- As soon as Pinterest completes the review, Pinterest will notify you by email.
- Once you have received the email approval, go to My Apps to see your app ID and secret key.
It's now time to copy/paste the app ID and secret key to the .env file.
Configure the redirect URI
The package provides a default redirect URI /pinterest/callack
. You are free to change it in your configuration file.
- Back to your Pinterest account.
- Go to My Apps and select your app.
- Go to Configure and, in Redirect URIs, enter the desired URI and save.
Note: For local development it's preferred to use
http://localhost/pinterest/callback
Generate an access token
- To start the OAuth flow and request user access run
php artisan pinterest:get-access-code-link
- Copy/Paste the link to your browser and follow the instructions on screen.
- At the end of the process you will see a white page with a text saying "All good! You can close this page."
Now you are ready to call the Pinterest API.
NOTES
Pinterest provides an access_token
valid for 30 days and a refresh_token
valid for 1 year.
The package automatically retrieves a new access token every time it expires, as long as the refresh token is still valid.
After 1 year, when you try to call an API endpoint, the package will throw a OAuthException
with a message informing you to request a new access code.
If you are curious you can read the codebase to learn more.
Or you can use Lemaur\Pinterest\Facades\Pinterest::oauth()->credentials()->accessTokenExpiresIn
to get the number of days before the access token will expire.
The same for the refresh token Lemaur\Pinterest\Facades\Pinterest::oauth()->credentials()->refreshTokenExpiresIn
.
Testing
The package offers a nifty fake method to help you write your tests.
If you want some examples, I suggest to look at the package test suite.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Maurizio
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-pinterest-api with dependencies
guzzlehttp/guzzle Version ^7.5
illuminate/contracts Version ^9.0|^10.0
spatie/laravel-package-tools Version ^1.14.0