Download the PHP package siapepfrance/pinterest-php-client without Composer

On this page you can find all versions of the php package siapepfrance/pinterest-php-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pinterest-php-client

Pinterest API V5+ - PHP

Scrutinizer Code Quality Packagist

A PHP client for the official Pinterest API V5+.

Requirements

Get started

To use the Pinterest API V5+ you have to register yourself as a developer and create an application. After you've created your app you will receive a app_id and app_secret.

The terms client_id and client_secret are in this case app_id and app_secret.

Installation

The Pinterest API V5+ wrapper is available on Github only so you need two steps to install it.

The Pinterest API V5+ client is available on Composer

If you're not using Composer (which you should start using, unless you've got a good reason not to) you can include the autoload.php file in your project.

Simple Example

After you have initialized the class you can get a login URL:

Check the Pinterest documentation for the available scopes.

After your user has used the login link to authorize he will be send back to the given REDIRECT_URI. The URL will contain the code which can be exchanged into an access_token. To exchange the code for an access_token and set it you can use the following code:

Get the user's account

To get the profile of the current logged in user you can use the UserAccounts::get(<array>); method.

Models

The API wrapper will parse all data through it's corresponding model. This results in the possibility to (for example) directly echo your model into a JSON string.

Models also show the available fields (which are also described in the Pinterest documentation). By default, not all fields are returned, so this can help you when providing extra fields to the request.

Available models

User Accounts

Boards

Pins

Ad Accounts

Retrieving extra fields

If you want more fields you can specify these in the $data (GET requests) or $fields (PATCH requests) array. Example:

Response:

Collection

When the API returns multiple models (for instance when your requesting the pins from a board) the wrapper will put those into a Collection.

The output of a collection contains the data and page key. If you echo the collection you will see a json encoded output containing both of these. Using the collection as an array will only return the items from data.

Available methods for the collection class:

Get all items

all()

Returns: array<Model>

Get item at index

get( int $index )

Returns: Model

Check if collection has next page

hasNextPage()

Get the next page if collection has next page

getNextPage()

Returns: Boolean

Get pagination data

Returns an array with an URL and cursor for the next page, or false when no next page is available.

pagination

Returns: Array

Available methods

Every method containing a data array can be filled with extra data. This can be for example extra fields or pagination.

Authentication

The methods below are available through $pinterest->auth.

Get login URL

getLoginUrl(string $redirect_uri, array $scopes, string $response_type = "code");

Check the Pinterest documentation for the available scopes.

Note: since 0.2.0 the default authentication method has changed to code instead of token. This means you have to exchange the returned code for an access_token.

Set redirect_uri (this method is useful when using the authorization_code flow to authenticate )

setRedirectUri( string $redirect_uri );

Get access_token

getOAuthToken( string $code );

Set access_token

setOAuthToken( string $access_token );

Refresh the expired access_token thanks to the refresh token

refreshOAuthToken( string $refresh_token );

Get state

getState();

Returns: string

Set state

setState( string $state );

This method can be used to set a state manually, but this isn't required since the API will automatically generate a random state on initialize.

Rate limit

Note that you should call an endpoint first, otherwise getRateLimit() will return unknown.

Get limit

getRateLimit();

This method can be used to get the maximum number of requests.

Returns: int

Get remaining

getRateLimitRemaining();

This method can be used to get the remaining number of calls.

Returns: int

User Accounts

The methods below are available through $pinterest->user_accounts.

You also cannot access a user’s boards or Pins who has not authorized your app.

Get logged in user account

get( array $data );

Returns: UserAccount

Get logged in user account analytics

getAnalytics( array $data );

Returns: Collection<UserAccountAnalytic>

Boards

The methods below are available through $pinterest->boards.

List boards

listBoards( array $data );

Returns: Collection<Board>

Get board

get( string $boardId, array $data );

Returns: Board

Create board

create( array $data );

Returns: Board

Edit board

edit( string $boardId, array $data, string $fields = null );

Returns: Board

Get board pins

delete( string $boardId, array $data );

Returns: Collection<Pin>

Delete board

delete( string $boardId, array $data );

Returns: True|PinterestException

Sections

The methods below are available through $pinterest->sections.

Create section on board

create( string $boardId, array $data );

Returns: Section

Update section on board

create( string $boardId, string $sectionId, array $data );

Returns: Section

Get sections on board

get( string $boardId, array $data );

Returns: Collection<Section>

Get pins from section

Note: Returned board ids can't directly be provided to pins(). The id needs to be extracted from \<BoardSection xxx>

get( string $boardId, string $sectionId, array $data );

Returns: Collection<Pin>

Delete section

delete( string $boardId, string $sectionId );

Returns: boolean

Pins

The methods below are available through $pinterest->pins.

Get pin

get( string $pinId, array $data );

Returns: Pin

Get pins from board

fromBoard( string $boardId, array $data );

Returns: Collection<Pin>

Create pin

create( array $data );

Creating a pin with an image hosted somewhere else:

Creating a pin with a base64 encoded image on the server:

Returns: Pin

Edit pin

edit( string $pinId, array $data, string $fields = null );

Returns: Pin

Delete pin

delete( string $pinId, array $data );

Returns: True|PinterestException

Ad Accounts

The methods below are available through $pinterest->ad_accounts.

You also cannot access a user’s boards or Pins who has not authorized your app.

Get ad accounts

get( array $data );

Returns: AdAccount

Get ad accounts analytics

getAnalytics( string $adAccountId, array $data );

Returns: Collection<AdAccountAnalytic>

Get ad accounts campaigns

getCampaigns( string $adAccountId, array $data );

Returns: Collection<AdCampaign>

Get ad account campaign analytics

getCampaignAnalytics( string $adAccountId, array $data );

Returns: Collection<AdCampaignAnalytic>

Get ad account groups

getAdGroups( string $adAccountId, array $data );

Returns: Collection<AdGroup>

Get ad account group analytics

getAdGroupAnalytics( string $adAccountId, array $data );

Returns: Collection<AdGroupAnalytic>

Get ad account ads

getAds( string $adAccountId, array $data );

Returns: Collection<Ad>

Get ad account ad analytics

getAdAnalytics( string $adAccountId, array $data );

Returns: Collection<AdAnalytic>

Examples

Use can take a look at the ./demo directory for a simple example.

Let me know if you have an (example) project using the this library.


All versions of pinterest-php-client with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
ext-curl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package siapepfrance/pinterest-php-client contains the following files

Loading the files please wait ....