From e2f7da82de04d49d40fec407315d5998ae03de7e Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Tue, 17 Jun 2014 11:43:09 +0200 Subject: [PATCH 01/17] Moved source to /src --- Api.php => src/Api.php | 0 Exception.php => src/Exception.php | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Api.php => src/Api.php (100%) rename Exception.php => src/Exception.php (100%) diff --git a/Api.php b/src/Api.php similarity index 100% rename from Api.php rename to src/Api.php diff --git a/Exception.php b/src/Exception.php similarity index 100% rename from Exception.php rename to src/Exception.php From 7456b8e856bdc3ef55d83f636d9cac6f82ae4431 Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Tue, 17 Jun 2014 11:43:20 +0200 Subject: [PATCH 02/17] Composer updated --- composer.json | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 8bfa6bb..43cb40c 100644 --- a/composer.json +++ b/composer.json @@ -1,10 +1,17 @@ { - "name": "forkcms/api-wrapper", + "name": "jeroendesloovere/fork-cms-php-api", "type": "library", - "description": "Wrapper class to communicate with your Fork install", - "homepage": "https://github.com/forkcms/api-wrapper-class", + "description": "This Fork CMS PHP class can communicate with a Fork CMS websites API.", + "keywords": ["Fork CMS", "CMS", "PHP", "API"], + "homepage": "https://github.com/jeroendesloovere/fork-cms-php-api", "license": "MIT", "authors": [ + { + "name": "Jeroen Desloovere", + "email": "info@jeroendesloovere.be", + "homepage": "http://jeroendesloovere.be", + "role": "Developer" + }, { "name": "Tijs Verkoyen", "email": "tijs@sumocoders.be", @@ -16,6 +23,8 @@ "ext-curl": "*" }, "autoload": { - "classmap": [""] + "psr-4": { + "ForkCms\\Api\\": "src/" + } } } \ No newline at end of file From 35f9e57d85e670c0de5635f8a4cf68dfb83d6c86 Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Tue, 17 Jun 2014 11:51:50 +0200 Subject: [PATCH 03/17] Credentials added --- examples/credentials.php | 11 +++++++++++ tests/index.php => examples/example.php | 6 +++--- tests/ApiTest.php | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 examples/credentials.php rename tests/index.php => examples/example.php (84%) diff --git a/examples/credentials.php b/examples/credentials.php new file mode 100644 index 0000000..83eba39 --- /dev/null +++ b/examples/credentials.php @@ -0,0 +1,11 @@ +coreGetAPIKey(EMAIL, PASSWORD); diff --git a/tests/ApiTest.php b/tests/ApiTest.php index c955582..947ef8b 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -1,7 +1,7 @@ Date: Tue, 17 Jun 2014 11:51:58 +0200 Subject: [PATCH 04/17] Class moved and renamed --- src/{Api.php => ForkCms.php} | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) rename src/{Api.php => ForkCms.php} (99%) diff --git a/src/Api.php b/src/ForkCms.php similarity index 99% rename from src/Api.php rename to src/ForkCms.php index 8dc3ec4..52155c5 100644 --- a/src/Api.php +++ b/src/ForkCms.php @@ -8,7 +8,7 @@ * @copyright Copyright (c) 2008, Tijs Verkoyen. All rights reserved. * @license BSD License */ -class Api +class ForkCms { // current version const VERSION = '1.0.1'; @@ -194,25 +194,25 @@ private function getSecret($nonce) } /** - * Get the useragent that will be used. Our version will be prepended to - * yours. - * It will look like: "PHP ForkAPI/ " + * Get the URL of the website we are working on * * @return string */ - public function getUserAgent() + public function getUrl() { - return 'PHP ForkAPI/'. self::VERSION .' '. $this->userAgent; + return $this->url; } /** - * Get the URL of the website we are working on + * Get the useragent that will be used. Our version will be prepended to + * yours. + * It will look like: "PHP ForkAPI/ " * * @return string */ - public function getUrl() + public function getUserAgent() { - return $this->url; + return 'PHP ForkAPI/'. self::VERSION .' '. $this->userAgent; } /** @@ -247,19 +247,6 @@ public function setTimeOut($seconds) $this->timeOut = (int) $seconds; } - /** - * Set the user-agent for you application - * It will be appended to ours, the result will look like: - * "PHP ForkAPI/ " - * - * @return void - * @param string $userAgent Your user-agent, it should look like /. - */ - public function setUserAgent($userAgent) - { - $this->userAgent = (string) $userAgent; - } - /** * Set the URL to work on * @@ -273,6 +260,19 @@ protected function setUrl($url) $this->url = (string) $url; } + /** + * Set the user-agent for you application + * It will be appended to ours, the result will look like: + * "PHP ForkAPI/ " + * + * @return void + * @param string $userAgent Your user-agent, it should look like /. + */ + public function setUserAgent($userAgent) + { + $this->userAgent = (string) $userAgent; + } + /** * Get the API key for a user * From 412f2c5e049b4ee02577c1d6d25d47d15d0fbc47 Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Tue, 17 Jun 2014 11:52:57 +0200 Subject: [PATCH 05/17] ApiTest renamed to ForkCmsTest --- tests/{ApiTest.php => ForkCmsTest.php} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename tests/{ApiTest.php => ForkCmsTest.php} (98%) diff --git a/tests/ApiTest.php b/tests/ForkCmsTest.php similarity index 98% rename from tests/ApiTest.php rename to tests/ForkCmsTest.php index 947ef8b..facb53f 100644 --- a/tests/ApiTest.php +++ b/tests/ForkCmsTest.php @@ -4,12 +4,12 @@ require_once __DIR__ . '/src/credentials.php'; require_once 'PHPUnit/Framework/TestCase.php'; -use \ForkCms\Api\Api; +use \ForkCms\Api\ForkCms; /** - * Api test case. + * Fork Cms Api test case. */ -class ApiTest extends PHPUnit_Framework_TestCase +class ForkCmsTest extends PHPUnit_Framework_TestCase { /** * @var Api From 6718e09d586825c041a37cda6f1c55eb1bb6eed1 Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Tue, 17 Jun 2014 11:58:22 +0200 Subject: [PATCH 06/17] Readme updated --- README.md | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6ad883a..c2cb8a7 100755 --- a/README.md +++ b/README.md @@ -1,10 +1,72 @@ -# ForkCMS Api class +# Fork CMS PHP API class +[![Latest Stable Version](http://img.shields.io/packagist/v/jeroendesloovere/fork-cms-php-api.svg)](https://packagist.org/packages/jeroendesloovere/fork-cms-php-api) +[![License](http://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/jeroendesloovere/fork-cms-php-api/blob/master/LICENSE) +[![Build Status](http://img.shields.io/travis/jeroendesloovere/fork-cms-php-api.svg)](https://travis-ci.org/jeroendesloovere/fork-cms-php-api) -## About +This Fork CMS PHP class can communicate with a Fork CMS websites API. -A (wrapper)class to communicate with the your Fork CMS install. +## Usage + +### Installation + +``` json +{ + "require": { + "jeroendesloovere/fork-cms-php-api": "1.0.*" + } +} +``` +> Adding this code in your `composer.json` file will get the [latest fork-cms-php-api Packagist package](https://packagist.org/packages/jeroendesloovere/fork-cms-php-api) using [Composer](https://getcomposer.org). + +### Example + +``` php +use ForkCms\Api\Api; + +$api = new ForkCms($url, $email, $apiKey); + +``` +> [View all examples](/examples/example.php) or check [the ForkCms class](/src/). + +### Tests + +``` bash +$ phpunit +``` ## Documentation -The class is well documented inline. If you use a decent IDE you'll see that -each method is documented with PHPDoc. \ No newline at end of file +The class is well documented inline. If you use a decent IDE you'll see that each method is documented with PHPDoc. + + +## Contributing + +Contributions are **welcome** and will be fully **credited**. + +### Pull Requests + +> To add or update code + +- **Coding Syntax** - Please keep the code syntax consistent with the rest of the package. +- **Add unit tests!** - Your patch won't be accepted if it doesn't have tests. +- **Document any change in behavior** - Make sure the README and any other relevant documentation are kept up-to-date. +- **Consider our release cycle** - We try to follow [semver](http://semver.org/). Randomly breaking public APIs is not an option. +- **Create topic branches** - Don't ask us to pull from your master branch. +- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. +- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting. + +### Issues + +> For bug reporting or code discussions. + +More info on how to work with GitHub on help.github.com. + +## Credits + +- [Tijs Verkoyen](https://github.com/tijsverkoyen) +- [Jeroen Desloovere](https://github.com/jeroendesloovere) +- [All Contributors](https://github.com/jeroendesloovere/fork-cms-php-api/contributors) + +## License + +The module is licensed under [MIT](./LICENSE.md). In short, this license allows you to do everything as long as the copyright statement stays present. \ No newline at end of file From be9d8f9cb39063390edf1b616822bdaa35b59851 Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Tue, 17 Jun 2014 13:31:52 +0200 Subject: [PATCH 07/17] Readme updated --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c2cb8a7..21a760b 100755 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![License](http://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/jeroendesloovere/fork-cms-php-api/blob/master/LICENSE) [![Build Status](http://img.shields.io/travis/jeroendesloovere/fork-cms-php-api.svg)](https://travis-ci.org/jeroendesloovere/fork-cms-php-api) -This Fork CMS PHP class can communicate with a Fork CMS websites API. +This Fork CMS PHP class can communicate with the API from a Fork CMS website. ## Usage From f8d6a16d669cfb25ad487f1857546f86e32a3bbb Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Tue, 17 Jun 2014 13:33:41 +0200 Subject: [PATCH 08/17] Readme updated with right class name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 21a760b..6331d7e 100755 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ This Fork CMS PHP class can communicate with the API from a Fork CMS website. ### Example ``` php -use ForkCms\Api\Api; +use ForkCms\Api\ForkCms; $api = new ForkCms($url, $email, $apiKey); From 1942223b2ec16f28cef4be0a4bea4aa5f7db9743 Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Tue, 16 Sep 2014 13:49:46 +0200 Subject: [PATCH 09/17] Indents fixed --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 43cb40c..b53427c 100644 --- a/composer.json +++ b/composer.json @@ -10,13 +10,13 @@ "name": "Jeroen Desloovere", "email": "info@jeroendesloovere.be", "homepage": "http://jeroendesloovere.be", - "role": "Developer" + "role": "Developer" }, - { - "name": "Tijs Verkoyen", - "email": "tijs@sumocoders.be", - "role": "Developer" - } + { + "name": "Tijs Verkoyen", + "email": "tijs@sumocoders.be", + "role": "Developer" + } ], "require": { "php": ">=5.3.0", From 5e30494886599fe47f817965493c11bdbd5a6a43 Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Tue, 26 May 2015 17:45:29 +0200 Subject: [PATCH 10/17] example updated --- examples/credentials.php | 14 +++++++++----- examples/example.php | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/examples/credentials.php b/examples/credentials.php index 83eba39..9425c20 100644 --- a/examples/credentials.php +++ b/examples/credentials.php @@ -1,11 +1,15 @@ coreGetAPIKey(EMAIL, PASSWORD); + // we get the api key for this user + $response = $api->coreGetAPIKey($email, $password); // $response = $api->coreGetInfo(); + + // we need to save the api key in our database + $apiKey = $response['api_key']; + + // we can set the api key or create a new Fork CMS Api instead. + $api->setApiKey($apiKey); +} catch (Exception $e) { + var_dump($e); +} + +// output +var_dump($response); + +// we can create a new Fork CMS API when we have the $apiKey +$api = new ForkCms( + $url, + $email, + $apiKey +); + +try { +// authorisation required for the following functions // $response = $api->coreAppleAddDevice(APPLE_DEVICE_TOKEN); // $response = $api->coreAppleRemoveDevice(APPLE_DEVICE_TOKEN); // $response = $api->blogCommentsGet(); @@ -24,3 +54,4 @@ // output var_dump($response); + From e024e8e4516834ba955793bb9ab8637ad4347f1f Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Wed, 27 May 2015 15:35:52 +0200 Subject: [PATCH 11/17] gitignore added --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..7fb2bd8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/vendor +composer.lock +/.idea +.DS_Store +Thumbs.db From 9262e0bce26af00505b80dbcd11a84d908cf7456 Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Wed, 27 May 2015 15:36:01 +0200 Subject: [PATCH 12/17] debugging files added --- .travis.yml | 21 +++++++++++++++++++++ phpunit.xml.dist | 16 ++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 .travis.yml create mode 100755 phpunit.xml.dist diff --git a/.travis.yml b/.travis.yml new file mode 100755 index 0000000..f64abe9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +language: php + +php: + - 5.4 + - 5.5 + - 5.6 + - hhvm + +sudo: false + +before_script: + - composer self-update + - composer install --prefer-source --no-interaction --dev + +script: + - phpunit --coverage-text + +matrix: + allow_failures: + - php: hhvm + fast_finish: true \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100755 index 0000000..31de95c --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,16 @@ + + + + + tests + + + + + src + + + From 672b665861463737dfe75c1bb980d80a87d5e12f Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Wed, 27 May 2015 15:36:07 +0200 Subject: [PATCH 13/17] composer updated --- composer.json | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index b53427c..1ab58c0 100644 --- a/composer.json +++ b/composer.json @@ -1,20 +1,20 @@ { - "name": "jeroendesloovere/fork-cms-php-api", + "name": "forkcms/api-wrapper-class", "type": "library", "description": "This Fork CMS PHP class can communicate with a Fork CMS websites API.", "keywords": ["Fork CMS", "CMS", "PHP", "API"], - "homepage": "https://github.com/jeroendesloovere/fork-cms-php-api", + "homepage": "https://github.com/forkcms/api-wrapper-class", "license": "MIT", "authors": [ { - "name": "Jeroen Desloovere", - "email": "info@jeroendesloovere.be", - "homepage": "http://jeroendesloovere.be", + "name": "Tijs Verkoyen", + "email": "tijs@sumocoders.be", "role": "Developer" }, { - "name": "Tijs Verkoyen", - "email": "tijs@sumocoders.be", + "name": "Jeroen Desloovere", + "email": "info@jeroendesloovere.be", + "homepage": "http://jeroendesloovere.be", "role": "Developer" } ], @@ -22,6 +22,9 @@ "php": ">=5.3.0", "ext-curl": "*" }, + "require-dev": { + "mockery/mockery": "dev-master@dev" + }, "autoload": { "psr-4": { "ForkCms\\Api\\": "src/" From f355cfd4af88d1c2e2c35f15e0fef0ea3ba78f35 Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Wed, 27 May 2015 15:36:13 +0200 Subject: [PATCH 14/17] Exception updated --- src/Exception.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Exception.php b/src/Exception.php index c183778..64d708a 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -1,4 +1,5 @@ Date: Wed, 27 May 2015 15:36:21 +0200 Subject: [PATCH 15/17] Fork CMS updated --- src/ForkCms.php | 7 +++---- tests/ForkCmsTest.php | 10 +++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ForkCms.php b/src/ForkCms.php index 52155c5..35bf945 100644 --- a/src/ForkCms.php +++ b/src/ForkCms.php @@ -3,10 +3,9 @@ namespace ForkCms\Api; /** - * @author Tijs Verkoyen - * @version 1.0.1 - * @copyright Copyright (c) 2008, Tijs Verkoyen. All rights reserved. - * @license BSD License + * Wrapper class for any Fork CMS API. + * + * @author Tijs Verkoyen */ class ForkCms { diff --git a/tests/ForkCmsTest.php b/tests/ForkCmsTest.php index facb53f..e50674e 100644 --- a/tests/ForkCmsTest.php +++ b/tests/ForkCmsTest.php @@ -1,13 +1,17 @@ + * @author Jeroen Desloovere */ class ForkCmsTest extends PHPUnit_Framework_TestCase { From dcc43812f5e3e5c0d19e5c0d8126fdfcee96a1a1 Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Wed, 27 May 2015 15:36:25 +0200 Subject: [PATCH 16/17] Examples updated --- examples/example.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/example.php b/examples/example.php index 8fc5028..660dfcb 100644 --- a/examples/example.php +++ b/examples/example.php @@ -7,8 +7,8 @@ use \ForkCms\Api\ForkCms; -// FIRST CONNECTION: getting API key so we can call functions which require authentication -// if we use a database we can save the $apiKey and skip this step the next time. +// Getting API KEY for function calls which require an Api key. +// Note: save the received Api key for later use. // init fork cms $api = new ForkCms( @@ -33,7 +33,7 @@ // output var_dump($response); -// we can create a new Fork CMS API when we have the $apiKey +// we can now create a new Fork CMS API where we fill in the $apiKey $api = new ForkCms( $url, $email, @@ -54,4 +54,3 @@ // output var_dump($response); - From f06d36e1afc13f166501936f2f84fd5af4f72f2d Mon Sep 17 00:00:00 2001 From: Jeroen Desloovere Date: Wed, 27 May 2015 15:36:29 +0200 Subject: [PATCH 17/17] Readme updated --- README.md | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6331d7e..ef3d2c6 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Fork CMS PHP API class -[![Latest Stable Version](http://img.shields.io/packagist/v/jeroendesloovere/fork-cms-php-api.svg)](https://packagist.org/packages/jeroendesloovere/fork-cms-php-api) -[![License](http://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/jeroendesloovere/fork-cms-php-api/blob/master/LICENSE) -[![Build Status](http://img.shields.io/travis/jeroendesloovere/fork-cms-php-api.svg)](https://travis-ci.org/jeroendesloovere/fork-cms-php-api) +[![Latest Stable Version](http://img.shields.io/packagist/v/forkcms/api-wrapper-class.svg)](https://packagist.org/packages/forkcms/api-wrapper-class) +[![License](http://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/forkcms/api-wrapper-class/blob/master/LICENSE) +[![Build Status](http://img.shields.io/travis/forkcms/api-wrapper-class.svg)](https://travis-ci.org/forkcms/api-wrapper-class) This Fork CMS PHP class can communicate with the API from a Fork CMS website. @@ -12,26 +12,51 @@ This Fork CMS PHP class can communicate with the API from a Fork CMS website. ``` json { "require": { - "jeroendesloovere/fork-cms-php-api": "1.0.*" + "forkcms/api-wrapper-class": "1.0.*" } } ``` -> Adding this code in your `composer.json` file will get the [latest fork-cms-php-api Packagist package](https://packagist.org/packages/jeroendesloovere/fork-cms-php-api) using [Composer](https://getcomposer.org). +> Adding this code in your `composer.json` file will get the [latest fork-cms-php-api Packagist package](https://packagist.org/packages/forkcms/api-wrapper-class) using [Composer](https://getcomposer.org). ### Example ``` php use ForkCms\Api\ForkCms; +``` + +**Function calls which do not require authentication** + +```php +$api = new ForkCms( + $url, + $email +); -$api = new ForkCms($url, $email, $apiKey); +$response = $api->coreGetAPIKey($email, $password); + +$apiKey = $response['api_key']; + +``` +**Function calls which require authentication** +```php +$api = new ForkCms( + $url, + $email, + $apiKey +); + +$response = $api->coreAppleAddDevice(APPLE_DEVICE_TOKEN); +$response = $api->coreAppleRemoveDevice(APPLE_DEVICE_TOKEN); +$response = $api->blogCommentsGet(); +// ... ``` -> [View all examples](/examples/example.php) or check [the ForkCms class](/src/). +> [View all examples](/examples/example.php) or check [the Fork CMS API Wrapper Class](/src/). ### Tests ``` bash -$ phpunit +phpunit ``` ## Documentation @@ -65,7 +90,7 @@ More info on how to work with GitHub on help.github.com. - [Tijs Verkoyen](https://github.com/tijsverkoyen) - [Jeroen Desloovere](https://github.com/jeroendesloovere) -- [All Contributors](https://github.com/jeroendesloovere/fork-cms-php-api/contributors) +- [All Contributors](https://github.com/forkcms/api-wrapper-class/contributors) ## License