PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Chun-Sheng, Li   PHP Web Service Bundle   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Web Service Bundle
Call APIs to email, shorten URLs and upload images
Author: By
Last change:
Date: 7 years ago
Size: 4,267 bytes
 

Contents

Class file image Download

serviceBundle

Build Status Latest Stable Version Total Downloads Latest Unstable Version License codecov

Integrating with mailing service,uploading image service and so on.

It's based on Guzzle,HTTP client.

Following service table is about supporting status

| service-name|support|service-type| |-------------|-------|------------| | mailgun| Yes | mailing service | | mailjet | No | mailing service | | sendgrid | No | mailing service | | Imgur | Yes | uploading images service | | bit.ly | Yes | shorten url service | | goo.gl | Yes | shorten url service | |McAf.ee| Yes | shorten url service |

Usage

Install Package

We strongly recommended using composer

Getting composer

  curl -sS https://getcomposer.org/installer | php

Using this command

  php composer.phar require lee/service-bundle

Sample code

Mailgun: a sending mail service

  require 'vendor/autoload.php';
  $config = array(
      'service-name' => 'mailgun',
      //e.g. key-98dXXXXXXX
      'api-key' => 'mailgun-api-key',
      //e.g. sandbox5099cXXXXXXXXXXXXXXXXXXX
      'domain-name' => 'mailgun-domain-name',
      'from' => 'peter279k@gmail.com',
      'to' => 'peter279k@gmail.com',
      'subject' => 'Hello',
      //contents supported only plain text now.
      'contents' => 'Mailgun is awesome !'
  );
  $bundle = new \peter\components\serviceBundle\serviceBundle($config);
  //return json format (mailgun standard api response via cURL)
  var_dump($bundle -> sendReq());

Imgur: an uploading images service

  require 'vendor/autoload.php';
  $config = array(
		'service-name' => 'imgur',
		'clientID' => 'imgur-client-id',
		'filePath' => '/path/to/image.png'
  );
  $bundle = new \peter\components\serviceBundle\serviceBundle($config);
  //return json format (Imgur standard api response via cURL)
  var_dump($bundle -> sendReq());

McAf: a shorten url service

  require 'vendor/autoload.php';
  $config = array(
		'service-name' => 'McAf.ee',
		'longUrl' => 'your-long-url'
  );
  $bundle = new \peter\components\serviceBundle\serviceBundle($config);
  //return json format (McAf standard api response via cURL)
  var_dump($bundle -> sendReq());

goo.gl: a shorten url service

  require 'vendor/autoload.php';
  $config = array(
		'service-name' => 'goo.gl',
		'apiKey' => 'your-api-key',
		'longUrl' => 'your-long-url'
  );
  $bundle = new \peter\components\serviceBundle\serviceBundle($config);
  //return json format (goo.gl standard api response via cURL)
  var_dump($bundle -> sendReq());

bit.ly: a shorten url service

  require 'vendor/autoload.php';
  $config = array(
		'service-name' => 'bit.ly',
		'login' => 'your-login',
		'apiKey' => 'your-api-key',
		'longUrl' => 'your-long-url'
  );
  $bundle = new \peter\components\serviceBundle\serviceBundle($config);
  //return json format (bit.ly standard api response via cURL)
  var_dump($bundle -> sendReq());

Changelog

2016/07/20

  • version: v1.2.7
  • Using the new version of Guzzle 5 and avoid the Httpoxy vulnerability.

2016/07/21

  • version: v1.2.8
  • Fix the uploading image via imgur service bug.

2016/07/21

  • version: v1.2.9
  • adding some information images