Download the PHP package eugenecooper/pinterest-php without Composer
On this page you can find all versions of the php package eugenecooper/pinterest-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eugenecooper/pinterest-php
More information about eugenecooper/pinterest-php
Files in eugenecooper/pinterest-php
Package pinterest-php
Short Description PHP Wrapper for consuming the Pinterest API.
License MIT
Informations about the package pinterest-php
Pinterest PHP
An easy-to-use wrapper for the Pinterest API.
Install
Via Composer
Usage
Authentication
To use the API, you need an access token from Pinterest. Create a new Pinterest application if you haven't already. You then get a client ID and a client secret, specific for that application.
Back in your PHP application, create a Pinterest\Http\ClientInterface
instance (the default is Pinterest\Http\BuzzClient
) and use it to create an Pinterest\Authentication
instance:
Replace the $clientId
and $clientSecret
variables with the data of your Pinterest application.
You can now let your user authenticate with your application be redirecting them to the URL obtained by a call to $auth->getAuthenticationUrl()
, like this:
- The redirect URL is the URL to the page where pinterest will send us the authentication code for the user registering with your application. This URL needs to be accessible over https, and it has to be filled into to form of your Pinterst application (in the Pinterest backend).
- The second parameter is an array of permissions your app needs on the user's account. There needs to be at least one here.
- The validation state is a random code that you generate for the user registering, and persist (in SESSION for instance). Pinterest will send it back to us for further reference.
When your application user agrees to let your app take control of their Pinterest account via the API, Pinterest will redirect them to the URL you provided as redirect URL, with some added GET parameters. The most important being "code", which we'll trade for an OAuth access token in the next step. They'll also send the validation state back to us as a GET parameter so we can check if we expected this call.
The last step in the process is trading that code for an access token:
You should persist that token safely at this point. You can use it from now on to connect to the Pinterest API from your application, on behalf of the user.
Initialize the Pinterest\Api
class:
Using the Pinterest\Api
instance in $api
, you can now make authenticated API requests to Pinterest's API on behalf of the user.
Get the authenticated user
Get a user
Get a board
Update a board
Get the boards of the authenticated user
Get the pins of the authenticated user
See Get the next items of a paged list
Get the pins of a board
See Get the next items of a paged list
Get the followers of the authenticated user
See Get the next items of a paged list
Get the boards that the authenticated user follows
See Get the next items of a paged list
Get the users that the authenticated user follows
See Get the next items of a paged list
Get the interests that the authenticated user follows
Example: Modern architecture
See Get the next items of a paged list
Follow a user
Create a board
Delete a board
Create a pin
Delete a pin
Get the next items of a paged list
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.