Download the PHP package cloudwelder/petitions-api without Composer

On this page you can find all versions of the php package cloudwelder/petitions-api. 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 petitions-api

Petitions.io API PHP Wrapper

This is PHP wrapper to Petitions.io API

Contents

Installation

Installation is done using composer. Run the following command to include this package into your project
composer require cloudwelder/petitions-api

Pre-requisites

In order to use this package, you must have an active App at petitions.io. If you dont already have one, register for one at petitions.io After the registration, note down your client_id, client_secret and redirect_uri OR you could get a personal access token directly.

Usage

Make sure you have the following line in your code before using any of the API classes. Thi is not required if you are using a framework such as laravel.

Initializing the API.

To use any of the APi calls, you must first get an instance of the API and acquier an access token using any of the following methods.

Methods 1: Using API credentials.

Substitute client_id, client_secret, redirect_uri with your own values.

Generating Login URL

To gain access rights from a user, you must first redirect him to petitions.io. You can use the getRedirectUrl() method to generate this url.

You can then use this url to reidrect the user or as the href of an html link.

Acquiring Access Token

Once the user has granted your app's access request, petitions.io will redirect the user to the url you have specified in redirect_uri settings in petitions.io. This is where you should acquire the access token using the autthorization code trnsmitted as part of the url.

Store this access_token into data base or other persistant storage to use it later. Unless the user revokes the grant, this access token is valid for a long time (a year)

The Token object retuned will also contain a refresh_token in addition to access_token. You can retrive it using getRfreshToken() function. Rrefresh tokens can be used to regenerate the access token when they expire.

Method 2: Using Personal Access Token.

If you alreay have an active personal access token, you can initialize the API without any credentials

Making API calls

The API object provides four methods for making API calls. They all return an instance of CloudWelder/PetitionsApi/Response. The returned object contains HTTP response related information such as headers, statsu code and response content. Petitions.io always return response in JSON format. So you must parse the response body to actually use the data. However the ressponse opbjecthas a helper method getResponseData() whcich will return an associative array generated by parsing the response content.

Before making any API calls, remeber to set the access token using the withToken() method. This method is chainable so you can chain other methods to it.

The four API call methods are:


All versions of petitions-api with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
guzzlehttp/guzzle Version ~6.0
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 cloudwelder/petitions-api contains the following files

Loading the files please wait ....