├── 01-importing-from-csv ├── .gitignore ├── README.md ├── composer.json ├── composer.lock ├── content.csv └── import.php ├── 02-exporting-to-csv ├── .gitignore ├── README.md ├── composer.json ├── composer.lock └── export.php ├── 03-creating-new-items ├── .gitignore ├── README.md ├── composer.json ├── composer.lock └── create.php ├── 04-import-from-sitemap ├── .gitignore ├── README.md ├── bin │ └── scrape ├── composer.json ├── composer.lock ├── fixtures │ ├── sample-page.html │ └── sample-sitemap.xml ├── spec │ ├── ContentScraperSpec.php │ ├── ContentToFieldMapperSpec.php │ ├── FieldNormaliserSpec.php │ ├── ImportCommandSpec.php │ └── SitemapScraperSpec.php └── src │ ├── ContentScraper.php │ ├── ContentToFieldMapper.php │ ├── FieldNormaliser.php │ ├── ImportCommand.php │ ├── ScrapeApplication.php │ └── SitemapScraper.php ├── 05-gravity-forms-add-on ├── .gitignore ├── README.md ├── composer.json ├── composer.lock ├── css │ └── admin.css ├── gravity_gc.php └── js │ └── admin.js ├── 06-export-report-to-csv ├── .gitignore ├── README.md ├── composer.json ├── composer.lock └── export.php ├── README.md └── Test CSV file.zip /01-importing-from-csv/.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | -------------------------------------------------------------------------------- /01-importing-from-csv/README.md: -------------------------------------------------------------------------------- 1 | # Importing from CSV 2 | 3 | Within this example, we will demonstrate how to import Items from a CSV file. 4 | 5 | Before we get started, ensure you change to the 01-importing-from-csv directory. 6 | 7 | ## Configure 8 | 9 | Insure you provide your credentials within the `import.php` script. 10 | 11 | ## Dependencies 12 | 13 | This example uses several dependencies to handle common tasks, such as making HTTP requests and working with CSV files, 14 | and also uses Composer to manage these dependencies. 15 | 16 | Install these dependencies with Composer by running: 17 | 18 | ```bash 19 | $ composer install 20 | ``` 21 | 22 | ## Run Example 23 | 24 | To run the example: 25 | 26 | ```bash 27 | $ php import.php 28 | ``` 29 | -------------------------------------------------------------------------------- /01-importing-from-csv/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "league/csv": "^7.2", 4 | "guzzlehttp/guzzle": "^6.1", 5 | "ramsey/uuid": "^3.0" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /01-importing-from-csv/composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "d87d008a40c0b2dbb3ba0a6d23dbfe82", 8 | "content-hash": "09ceb99b0f23b1d56358e46ae1a97da6", 9 | "packages": [ 10 | { 11 | "name": "guzzlehttp/guzzle", 12 | "version": "6.1.0", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/guzzle/guzzle.git", 16 | "reference": "66fd14b4d0b8f2389eaf37c5458608c7cb793a81" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/guzzle/guzzle/zipball/66fd14b4d0b8f2389eaf37c5458608c7cb793a81", 21 | "reference": "66fd14b4d0b8f2389eaf37c5458608c7cb793a81", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "guzzlehttp/promises": "~1.0", 26 | "guzzlehttp/psr7": "~1.1", 27 | "php": ">=5.5.0" 28 | }, 29 | "require-dev": { 30 | "ext-curl": "*", 31 | "phpunit/phpunit": "~4.0", 32 | "psr/log": "~1.0" 33 | }, 34 | "type": "library", 35 | "extra": { 36 | "branch-alias": { 37 | "dev-master": "6.1-dev" 38 | } 39 | }, 40 | "autoload": { 41 | "files": [ 42 | "src/functions_include.php" 43 | ], 44 | "psr-4": { 45 | "GuzzleHttp\\": "src/" 46 | } 47 | }, 48 | "notification-url": "https://packagist.org/downloads/", 49 | "license": [ 50 | "MIT" 51 | ], 52 | "authors": [ 53 | { 54 | "name": "Michael Dowling", 55 | "email": "mtdowling@gmail.com", 56 | "homepage": "https://github.com/mtdowling" 57 | } 58 | ], 59 | "description": "Guzzle is a PHP HTTP client library", 60 | "homepage": "http://guzzlephp.org/", 61 | "keywords": [ 62 | "client", 63 | "curl", 64 | "framework", 65 | "http", 66 | "http client", 67 | "rest", 68 | "web service" 69 | ], 70 | "time": "2015-09-08 17:36:26" 71 | }, 72 | { 73 | "name": "guzzlehttp/promises", 74 | "version": "1.0.3", 75 | "source": { 76 | "type": "git", 77 | "url": "https://github.com/guzzle/promises.git", 78 | "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea" 79 | }, 80 | "dist": { 81 | "type": "zip", 82 | "url": "https://api.github.com/repos/guzzle/promises/zipball/b1e1c0d55f8083c71eda2c28c12a228d708294ea", 83 | "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea", 84 | "shasum": "" 85 | }, 86 | "require": { 87 | "php": ">=5.5.0" 88 | }, 89 | "require-dev": { 90 | "phpunit/phpunit": "~4.0" 91 | }, 92 | "type": "library", 93 | "extra": { 94 | "branch-alias": { 95 | "dev-master": "1.0-dev" 96 | } 97 | }, 98 | "autoload": { 99 | "psr-4": { 100 | "GuzzleHttp\\Promise\\": "src/" 101 | }, 102 | "files": [ 103 | "src/functions_include.php" 104 | ] 105 | }, 106 | "notification-url": "https://packagist.org/downloads/", 107 | "license": [ 108 | "MIT" 109 | ], 110 | "authors": [ 111 | { 112 | "name": "Michael Dowling", 113 | "email": "mtdowling@gmail.com", 114 | "homepage": "https://github.com/mtdowling" 115 | } 116 | ], 117 | "description": "Guzzle promises library", 118 | "keywords": [ 119 | "promise" 120 | ], 121 | "time": "2015-10-15 22:28:00" 122 | }, 123 | { 124 | "name": "guzzlehttp/psr7", 125 | "version": "1.2.1", 126 | "source": { 127 | "type": "git", 128 | "url": "https://github.com/guzzle/psr7.git", 129 | "reference": "4d0bdbe1206df7440219ce14c972aa57cc5e4982" 130 | }, 131 | "dist": { 132 | "type": "zip", 133 | "url": "https://api.github.com/repos/guzzle/psr7/zipball/4d0bdbe1206df7440219ce14c972aa57cc5e4982", 134 | "reference": "4d0bdbe1206df7440219ce14c972aa57cc5e4982", 135 | "shasum": "" 136 | }, 137 | "require": { 138 | "php": ">=5.4.0", 139 | "psr/http-message": "~1.0" 140 | }, 141 | "provide": { 142 | "psr/http-message-implementation": "1.0" 143 | }, 144 | "require-dev": { 145 | "phpunit/phpunit": "~4.0" 146 | }, 147 | "type": "library", 148 | "extra": { 149 | "branch-alias": { 150 | "dev-master": "1.0-dev" 151 | } 152 | }, 153 | "autoload": { 154 | "psr-4": { 155 | "GuzzleHttp\\Psr7\\": "src/" 156 | }, 157 | "files": [ 158 | "src/functions_include.php" 159 | ] 160 | }, 161 | "notification-url": "https://packagist.org/downloads/", 162 | "license": [ 163 | "MIT" 164 | ], 165 | "authors": [ 166 | { 167 | "name": "Michael Dowling", 168 | "email": "mtdowling@gmail.com", 169 | "homepage": "https://github.com/mtdowling" 170 | } 171 | ], 172 | "description": "PSR-7 message implementation", 173 | "keywords": [ 174 | "http", 175 | "message", 176 | "stream", 177 | "uri" 178 | ], 179 | "time": "2015-11-03 01:34:55" 180 | }, 181 | { 182 | "name": "league/csv", 183 | "version": "7.2.0", 184 | "source": { 185 | "type": "git", 186 | "url": "https://github.com/thephpleague/csv.git", 187 | "reference": "69bafa6ff924fbf9effe4275d6eb16be81a853ef" 188 | }, 189 | "dist": { 190 | "type": "zip", 191 | "url": "https://api.github.com/repos/thephpleague/csv/zipball/69bafa6ff924fbf9effe4275d6eb16be81a853ef", 192 | "reference": "69bafa6ff924fbf9effe4275d6eb16be81a853ef", 193 | "shasum": "" 194 | }, 195 | "require": { 196 | "ext-mbstring": "*", 197 | "php": ">=5.4.0" 198 | }, 199 | "require-dev": { 200 | "fabpot/php-cs-fixer": "^1.9", 201 | "phpunit/phpunit": "^4.0" 202 | }, 203 | "type": "library", 204 | "extra": { 205 | "branch-alias": { 206 | "dev-master": "7.2-dev" 207 | } 208 | }, 209 | "autoload": { 210 | "psr-4": { 211 | "League\\Csv\\": "src" 212 | } 213 | }, 214 | "notification-url": "https://packagist.org/downloads/", 215 | "license": [ 216 | "MIT" 217 | ], 218 | "authors": [ 219 | { 220 | "name": "Ignace Nyamagana Butera", 221 | "email": "nyamsprod@gmail.com", 222 | "homepage": "https://github.com/nyamsprod/", 223 | "role": "Developer" 224 | } 225 | ], 226 | "description": "Csv data manipulation made easy in PHP", 227 | "homepage": "http://csv.thephpleague.com", 228 | "keywords": [ 229 | "csv", 230 | "export", 231 | "filter", 232 | "import", 233 | "read", 234 | "write" 235 | ], 236 | "time": "2015-11-02 07:36:25" 237 | }, 238 | { 239 | "name": "psr/http-message", 240 | "version": "1.0", 241 | "source": { 242 | "type": "git", 243 | "url": "https://github.com/php-fig/http-message.git", 244 | "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298" 245 | }, 246 | "dist": { 247 | "type": "zip", 248 | "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", 249 | "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", 250 | "shasum": "" 251 | }, 252 | "require": { 253 | "php": ">=5.3.0" 254 | }, 255 | "type": "library", 256 | "extra": { 257 | "branch-alias": { 258 | "dev-master": "1.0.x-dev" 259 | } 260 | }, 261 | "autoload": { 262 | "psr-4": { 263 | "Psr\\Http\\Message\\": "src/" 264 | } 265 | }, 266 | "notification-url": "https://packagist.org/downloads/", 267 | "license": [ 268 | "MIT" 269 | ], 270 | "authors": [ 271 | { 272 | "name": "PHP-FIG", 273 | "homepage": "http://www.php-fig.org/" 274 | } 275 | ], 276 | "description": "Common interface for HTTP messages", 277 | "keywords": [ 278 | "http", 279 | "http-message", 280 | "psr", 281 | "psr-7", 282 | "request", 283 | "response" 284 | ], 285 | "time": "2015-05-04 20:22:00" 286 | }, 287 | { 288 | "name": "ramsey/uuid", 289 | "version": "3.0.1", 290 | "source": { 291 | "type": "git", 292 | "url": "https://github.com/ramsey/uuid.git", 293 | "reference": "3c84b9e2965a5fa666dec8617a3a66a8179c6ca8" 294 | }, 295 | "dist": { 296 | "type": "zip", 297 | "url": "https://api.github.com/repos/ramsey/uuid/zipball/3c84b9e2965a5fa666dec8617a3a66a8179c6ca8", 298 | "reference": "3c84b9e2965a5fa666dec8617a3a66a8179c6ca8", 299 | "shasum": "" 300 | }, 301 | "require": { 302 | "php": ">=5.4" 303 | }, 304 | "replace": { 305 | "rhumsaa/uuid": "self.version" 306 | }, 307 | "require-dev": { 308 | "apigen/apigen": "^4.1", 309 | "ircmaxell/random-lib": "^1.1", 310 | "jakub-onderka/php-parallel-lint": "^0.9.0", 311 | "moontoast/math": "^1.1", 312 | "phpunit/phpunit": "^4.7", 313 | "satooshi/php-coveralls": "^0.6.1", 314 | "squizlabs/php_codesniffer": "^2.3" 315 | }, 316 | "suggest": { 317 | "ext-uuid": "Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator", 318 | "ircmaxell/random-lib": "Provides RandomLib for use with the RandomLibAdapter", 319 | "moontoast/math": "Provides support for converting UUID to 128-bit integer (in string form).", 320 | "ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid", 321 | "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." 322 | }, 323 | "type": "library", 324 | "autoload": { 325 | "psr-4": { 326 | "Ramsey\\Uuid\\": "src/" 327 | } 328 | }, 329 | "notification-url": "https://packagist.org/downloads/", 330 | "license": [ 331 | "MIT" 332 | ], 333 | "authors": [ 334 | { 335 | "name": "Marijn Huizendveld", 336 | "email": "marijn.huizendveld@gmail.com" 337 | }, 338 | { 339 | "name": "Thibaud Fabre", 340 | "email": "thibaud@aztech.io" 341 | }, 342 | { 343 | "name": "Ben Ramsey", 344 | "email": "ben@benramsey.com", 345 | "homepage": "https://benramsey.com" 346 | } 347 | ], 348 | "description": "Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).", 349 | "homepage": "https://github.com/ramsey/uuid", 350 | "keywords": [ 351 | "guid", 352 | "identifier", 353 | "uuid" 354 | ], 355 | "time": "2015-10-21 16:27:25" 356 | } 357 | ], 358 | "packages-dev": [], 359 | "aliases": [], 360 | "minimum-stability": "stable", 361 | "stability-flags": [], 362 | "prefer-stable": false, 363 | "prefer-lowest": false, 364 | "platform": [], 365 | "platform-dev": [] 366 | } 367 | -------------------------------------------------------------------------------- /01-importing-from-csv/content.csv: -------------------------------------------------------------------------------- 1 | First name,Last name,Email,Bio 2 | Andrew,Cairns,andrew@gathercontent.com,"Passionate about Domain-Driven Design, Test-Driven Development, System Architecture and Agile Methodologies" 3 | Angus,Edwardson,angus@gathercontent.com,"Focussed on researching, developing and refining products and the problems they solve" -------------------------------------------------------------------------------- /01-importing-from-csv/import.php: -------------------------------------------------------------------------------- 1 | 'https://api.gathercontent.com', 13 | 'headers' => [ 14 | 'Accept' => 'application/vnd.gathercontent.v0.5+json' 15 | ], 16 | 'auth' => [ 17 | $username, 18 | $apikey 19 | ] 20 | ]); 21 | 22 | // @link https://gathercontent.com/developers/projects/post-projects/ 23 | $createProjectResponse = $client->post('/projects', [ 24 | 'form_params' => [ 25 | 'account_id' => 12975, 26 | 'name' => 'Employee Bios (Importing Example)', 27 | ] 28 | ]); 29 | 30 | // Get the location of the new project 31 | $projectLocation = $createProjectResponse->getHeader('Location')[0]; 32 | 33 | // @link https://gathercontent.com/developers/projects/get-projects/ 34 | $project = json_decode($client->get($projectLocation)->getBody(), true)['data']; 35 | 36 | // Read CSV file 37 | $csv = Reader::createFromPath('content.csv'); 38 | 39 | // Grab the first row as headings 40 | $headings = $csv->fetchOne(); 41 | 42 | // Grab all other rows as items 43 | $items = $csv->setOffset(1)->fetchAll(); 44 | 45 | foreach ($items as $item) { 46 | 47 | // Each Item must have a tab 48 | $tab = [ 49 | "label" => "Content", 50 | "name" => Uuid::uuid4()->toString(), 51 | "hidden" => false, 52 | "elements" => [] 53 | ]; 54 | 55 | // Add text elements to the tab 56 | foreach ($item as $index => $element) { 57 | $tab['elements'][] = [ 58 | "type" => "text", 59 | "name" => Uuid::uuid4()->toString(), 60 | "required" => false, 61 | "label" => $headings[$index], 62 | "value" => "

{$element}

", 63 | "microcopy" => "", 64 | "limit_type" => "words", 65 | "limit" => 0, 66 | "plain_text" => false 67 | ]; 68 | } 69 | 70 | // Use the first name and last name for the Item name 71 | $itemName = $item[0] . ' ' . $item[1]; 72 | 73 | // Create the new Item 74 | $client->post('/items', [ 75 | 'form_params' => [ 76 | 'project_id' => $project['id'], 77 | 'name' => $itemName, 78 | 'config' => base64_encode(json_encode([$tab])) 79 | ] 80 | ]); 81 | 82 | echo "{$itemName}: Created.\n"; 83 | } 84 | -------------------------------------------------------------------------------- /02-exporting-to-csv/.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | content.csv 3 | -------------------------------------------------------------------------------- /02-exporting-to-csv/README.md: -------------------------------------------------------------------------------- 1 | # Exporting to CSV 2 | 3 | Within this example, we will demonstrate how to export Items to a CSV file. 4 | 5 | Before we get started, ensure you change to the 02-exporting-to-csv directory. 6 | 7 | ## Configure 8 | 9 | Insure you provide your credentials and Project ID within the `export.php` script. 10 | 11 | ## Dependencies 12 | 13 | This example uses several dependencies to handle common tasks, such as making HTTP requests and working with CSV files, 14 | and also uses Composer to manage these dependencies. 15 | 16 | Install these dependencies with Composer by running: 17 | 18 | ```bash 19 | $ composer install 20 | ``` 21 | 22 | ## Run Example 23 | 24 | To run the example: 25 | 26 | ```bash 27 | $ php export.php 28 | ``` 29 | 30 | The example will create the `content.csv` file. 31 | -------------------------------------------------------------------------------- /02-exporting-to-csv/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "guzzlehttp/guzzle": "^6.1", 4 | "league/csv": "^7.2" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /02-exporting-to-csv/composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "318cbe5655d24f4d55bc4f9ba02f265a", 8 | "content-hash": "6528684c2709f3a1badeadaae2e81768", 9 | "packages": [ 10 | { 11 | "name": "guzzlehttp/guzzle", 12 | "version": "6.1.0", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/guzzle/guzzle.git", 16 | "reference": "66fd14b4d0b8f2389eaf37c5458608c7cb793a81" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/guzzle/guzzle/zipball/66fd14b4d0b8f2389eaf37c5458608c7cb793a81", 21 | "reference": "66fd14b4d0b8f2389eaf37c5458608c7cb793a81", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "guzzlehttp/promises": "~1.0", 26 | "guzzlehttp/psr7": "~1.1", 27 | "php": ">=5.5.0" 28 | }, 29 | "require-dev": { 30 | "ext-curl": "*", 31 | "phpunit/phpunit": "~4.0", 32 | "psr/log": "~1.0" 33 | }, 34 | "type": "library", 35 | "extra": { 36 | "branch-alias": { 37 | "dev-master": "6.1-dev" 38 | } 39 | }, 40 | "autoload": { 41 | "files": [ 42 | "src/functions_include.php" 43 | ], 44 | "psr-4": { 45 | "GuzzleHttp\\": "src/" 46 | } 47 | }, 48 | "notification-url": "https://packagist.org/downloads/", 49 | "license": [ 50 | "MIT" 51 | ], 52 | "authors": [ 53 | { 54 | "name": "Michael Dowling", 55 | "email": "mtdowling@gmail.com", 56 | "homepage": "https://github.com/mtdowling" 57 | } 58 | ], 59 | "description": "Guzzle is a PHP HTTP client library", 60 | "homepage": "http://guzzlephp.org/", 61 | "keywords": [ 62 | "client", 63 | "curl", 64 | "framework", 65 | "http", 66 | "http client", 67 | "rest", 68 | "web service" 69 | ], 70 | "time": "2015-09-08 17:36:26" 71 | }, 72 | { 73 | "name": "guzzlehttp/promises", 74 | "version": "1.0.3", 75 | "source": { 76 | "type": "git", 77 | "url": "https://github.com/guzzle/promises.git", 78 | "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea" 79 | }, 80 | "dist": { 81 | "type": "zip", 82 | "url": "https://api.github.com/repos/guzzle/promises/zipball/b1e1c0d55f8083c71eda2c28c12a228d708294ea", 83 | "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea", 84 | "shasum": "" 85 | }, 86 | "require": { 87 | "php": ">=5.5.0" 88 | }, 89 | "require-dev": { 90 | "phpunit/phpunit": "~4.0" 91 | }, 92 | "type": "library", 93 | "extra": { 94 | "branch-alias": { 95 | "dev-master": "1.0-dev" 96 | } 97 | }, 98 | "autoload": { 99 | "psr-4": { 100 | "GuzzleHttp\\Promise\\": "src/" 101 | }, 102 | "files": [ 103 | "src/functions_include.php" 104 | ] 105 | }, 106 | "notification-url": "https://packagist.org/downloads/", 107 | "license": [ 108 | "MIT" 109 | ], 110 | "authors": [ 111 | { 112 | "name": "Michael Dowling", 113 | "email": "mtdowling@gmail.com", 114 | "homepage": "https://github.com/mtdowling" 115 | } 116 | ], 117 | "description": "Guzzle promises library", 118 | "keywords": [ 119 | "promise" 120 | ], 121 | "time": "2015-10-15 22:28:00" 122 | }, 123 | { 124 | "name": "guzzlehttp/psr7", 125 | "version": "1.2.1", 126 | "source": { 127 | "type": "git", 128 | "url": "https://github.com/guzzle/psr7.git", 129 | "reference": "4d0bdbe1206df7440219ce14c972aa57cc5e4982" 130 | }, 131 | "dist": { 132 | "type": "zip", 133 | "url": "https://api.github.com/repos/guzzle/psr7/zipball/4d0bdbe1206df7440219ce14c972aa57cc5e4982", 134 | "reference": "4d0bdbe1206df7440219ce14c972aa57cc5e4982", 135 | "shasum": "" 136 | }, 137 | "require": { 138 | "php": ">=5.4.0", 139 | "psr/http-message": "~1.0" 140 | }, 141 | "provide": { 142 | "psr/http-message-implementation": "1.0" 143 | }, 144 | "require-dev": { 145 | "phpunit/phpunit": "~4.0" 146 | }, 147 | "type": "library", 148 | "extra": { 149 | "branch-alias": { 150 | "dev-master": "1.0-dev" 151 | } 152 | }, 153 | "autoload": { 154 | "psr-4": { 155 | "GuzzleHttp\\Psr7\\": "src/" 156 | }, 157 | "files": [ 158 | "src/functions_include.php" 159 | ] 160 | }, 161 | "notification-url": "https://packagist.org/downloads/", 162 | "license": [ 163 | "MIT" 164 | ], 165 | "authors": [ 166 | { 167 | "name": "Michael Dowling", 168 | "email": "mtdowling@gmail.com", 169 | "homepage": "https://github.com/mtdowling" 170 | } 171 | ], 172 | "description": "PSR-7 message implementation", 173 | "keywords": [ 174 | "http", 175 | "message", 176 | "stream", 177 | "uri" 178 | ], 179 | "time": "2015-11-03 01:34:55" 180 | }, 181 | { 182 | "name": "league/csv", 183 | "version": "7.2.0", 184 | "source": { 185 | "type": "git", 186 | "url": "https://github.com/thephpleague/csv.git", 187 | "reference": "69bafa6ff924fbf9effe4275d6eb16be81a853ef" 188 | }, 189 | "dist": { 190 | "type": "zip", 191 | "url": "https://api.github.com/repos/thephpleague/csv/zipball/69bafa6ff924fbf9effe4275d6eb16be81a853ef", 192 | "reference": "69bafa6ff924fbf9effe4275d6eb16be81a853ef", 193 | "shasum": "" 194 | }, 195 | "require": { 196 | "ext-mbstring": "*", 197 | "php": ">=5.4.0" 198 | }, 199 | "require-dev": { 200 | "fabpot/php-cs-fixer": "^1.9", 201 | "phpunit/phpunit": "^4.0" 202 | }, 203 | "type": "library", 204 | "extra": { 205 | "branch-alias": { 206 | "dev-master": "7.2-dev" 207 | } 208 | }, 209 | "autoload": { 210 | "psr-4": { 211 | "League\\Csv\\": "src" 212 | } 213 | }, 214 | "notification-url": "https://packagist.org/downloads/", 215 | "license": [ 216 | "MIT" 217 | ], 218 | "authors": [ 219 | { 220 | "name": "Ignace Nyamagana Butera", 221 | "email": "nyamsprod@gmail.com", 222 | "homepage": "https://github.com/nyamsprod/", 223 | "role": "Developer" 224 | } 225 | ], 226 | "description": "Csv data manipulation made easy in PHP", 227 | "homepage": "http://csv.thephpleague.com", 228 | "keywords": [ 229 | "csv", 230 | "export", 231 | "filter", 232 | "import", 233 | "read", 234 | "write" 235 | ], 236 | "time": "2015-11-02 07:36:25" 237 | }, 238 | { 239 | "name": "psr/http-message", 240 | "version": "1.0", 241 | "source": { 242 | "type": "git", 243 | "url": "https://github.com/php-fig/http-message.git", 244 | "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298" 245 | }, 246 | "dist": { 247 | "type": "zip", 248 | "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", 249 | "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", 250 | "shasum": "" 251 | }, 252 | "require": { 253 | "php": ">=5.3.0" 254 | }, 255 | "type": "library", 256 | "extra": { 257 | "branch-alias": { 258 | "dev-master": "1.0.x-dev" 259 | } 260 | }, 261 | "autoload": { 262 | "psr-4": { 263 | "Psr\\Http\\Message\\": "src/" 264 | } 265 | }, 266 | "notification-url": "https://packagist.org/downloads/", 267 | "license": [ 268 | "MIT" 269 | ], 270 | "authors": [ 271 | { 272 | "name": "PHP-FIG", 273 | "homepage": "http://www.php-fig.org/" 274 | } 275 | ], 276 | "description": "Common interface for HTTP messages", 277 | "keywords": [ 278 | "http", 279 | "http-message", 280 | "psr", 281 | "psr-7", 282 | "request", 283 | "response" 284 | ], 285 | "time": "2015-05-04 20:22:00" 286 | } 287 | ], 288 | "packages-dev": [], 289 | "aliases": [], 290 | "minimum-stability": "stable", 291 | "stability-flags": [], 292 | "prefer-stable": false, 293 | "prefer-lowest": false, 294 | "platform": [], 295 | "platform-dev": [] 296 | } 297 | -------------------------------------------------------------------------------- /02-exporting-to-csv/export.php: -------------------------------------------------------------------------------- 1 | 'https://api.gathercontent.com', 16 | 'headers' => [ 17 | 'Accept' => 'application/vnd.gathercontent.v0.5+json' 18 | ], 19 | 'auth' => [ 20 | $username, 21 | $apikey 22 | ] 23 | ]); 24 | 25 | // @link https://gathercontent.com/developers/items/get-items/ 26 | $itemListResponse = $client->get('/items', [ 27 | 'query' => [ 28 | 'project_id' => $projectId 29 | ] 30 | ]); 31 | 32 | $items = json_decode($itemListResponse->getBody(), true)['data']; 33 | 34 | 35 | /* 36 | * Asynchronously fetch each Item 37 | */ 38 | $promises = array_map(function ($item) use ($client) { 39 | return $client->getAsync('/items/' . $item['id']); 40 | }, $items); 41 | 42 | $promiseResponses = settle($promises)->wait(); 43 | 44 | $encodedItemResponses = array_column($promiseResponses, 'value'); 45 | 46 | $itemConfigs = array_map(function ($response) { 47 | return json_decode($response->getBody(), true)['data']['config']; 48 | }, $encodedItemResponses); 49 | 50 | $headings = array_column($itemConfigs[0][0]['elements'], 'label'); 51 | 52 | /* 53 | * Extract the 'value' from each of the Item elements 54 | */ 55 | $content = array_map(function ($itemConfig) { 56 | return array_column($itemConfig[0]['elements'], 'value'); 57 | }, $itemConfigs); 58 | 59 | /* 60 | * Create the CSV File 61 | */ 62 | 63 | touch('content.csv'); 64 | 65 | $csv = Writer::createFromPath('content.csv'); 66 | 67 | $csv->insertOne($headings); 68 | 69 | array_walk($content, function ($item) use ($csv) { 70 | $csv->insertOne($item); 71 | }); 72 | -------------------------------------------------------------------------------- /03-creating-new-items/.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | -------------------------------------------------------------------------------- /03-creating-new-items/README.md: -------------------------------------------------------------------------------- 1 | # Creating New Items 2 | 3 | This example will demonstrate how to create custom Items. 4 | 5 | Before we get started, ensure you change to the 03-creating-new-items directory. 6 | 7 | ## Configure 8 | 9 | Insure you provide your credentials and Project ID within the `create.php` script. 10 | 11 | ## Dependencies 12 | 13 | This example uses several dependencies to handle common tasks, such as making HTTP requests and working with UUIDs, 14 | and also uses Composer to manage these dependencies. 15 | 16 | Install these dependencies with Composer by running: 17 | 18 | ```bash 19 | $ composer install 20 | ``` 21 | 22 | ## Run Example 23 | 24 | To run the example: 25 | 26 | ```bash 27 | $ php create.php 28 | ``` 29 | 30 | The example will create the new Item within your Project. 31 | -------------------------------------------------------------------------------- /03-creating-new-items/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "guzzlehttp/guzzle": "^6.1", 4 | "ramsey/uuid": "^3.0" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /03-creating-new-items/composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "ed02e4eaabe8470fa2d5b0f2afee358a", 8 | "content-hash": "ce01d30bc91e1af8ceee622ebae94dd0", 9 | "packages": [ 10 | { 11 | "name": "guzzlehttp/guzzle", 12 | "version": "6.1.1", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/guzzle/guzzle.git", 16 | "reference": "c6851d6e48f63b69357cbfa55bca116448140e0c" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/guzzle/guzzle/zipball/c6851d6e48f63b69357cbfa55bca116448140e0c", 21 | "reference": "c6851d6e48f63b69357cbfa55bca116448140e0c", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "guzzlehttp/promises": "~1.0", 26 | "guzzlehttp/psr7": "~1.1", 27 | "php": ">=5.5.0" 28 | }, 29 | "require-dev": { 30 | "ext-curl": "*", 31 | "phpunit/phpunit": "~4.0", 32 | "psr/log": "~1.0" 33 | }, 34 | "type": "library", 35 | "extra": { 36 | "branch-alias": { 37 | "dev-master": "6.1-dev" 38 | } 39 | }, 40 | "autoload": { 41 | "files": [ 42 | "src/functions_include.php" 43 | ], 44 | "psr-4": { 45 | "GuzzleHttp\\": "src/" 46 | } 47 | }, 48 | "notification-url": "https://packagist.org/downloads/", 49 | "license": [ 50 | "MIT" 51 | ], 52 | "authors": [ 53 | { 54 | "name": "Michael Dowling", 55 | "email": "mtdowling@gmail.com", 56 | "homepage": "https://github.com/mtdowling" 57 | } 58 | ], 59 | "description": "Guzzle is a PHP HTTP client library", 60 | "homepage": "http://guzzlephp.org/", 61 | "keywords": [ 62 | "client", 63 | "curl", 64 | "framework", 65 | "http", 66 | "http client", 67 | "rest", 68 | "web service" 69 | ], 70 | "time": "2015-11-23 00:47:50" 71 | }, 72 | { 73 | "name": "guzzlehttp/promises", 74 | "version": "1.0.3", 75 | "source": { 76 | "type": "git", 77 | "url": "https://github.com/guzzle/promises.git", 78 | "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea" 79 | }, 80 | "dist": { 81 | "type": "zip", 82 | "url": "https://api.github.com/repos/guzzle/promises/zipball/b1e1c0d55f8083c71eda2c28c12a228d708294ea", 83 | "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea", 84 | "shasum": "" 85 | }, 86 | "require": { 87 | "php": ">=5.5.0" 88 | }, 89 | "require-dev": { 90 | "phpunit/phpunit": "~4.0" 91 | }, 92 | "type": "library", 93 | "extra": { 94 | "branch-alias": { 95 | "dev-master": "1.0-dev" 96 | } 97 | }, 98 | "autoload": { 99 | "psr-4": { 100 | "GuzzleHttp\\Promise\\": "src/" 101 | }, 102 | "files": [ 103 | "src/functions_include.php" 104 | ] 105 | }, 106 | "notification-url": "https://packagist.org/downloads/", 107 | "license": [ 108 | "MIT" 109 | ], 110 | "authors": [ 111 | { 112 | "name": "Michael Dowling", 113 | "email": "mtdowling@gmail.com", 114 | "homepage": "https://github.com/mtdowling" 115 | } 116 | ], 117 | "description": "Guzzle promises library", 118 | "keywords": [ 119 | "promise" 120 | ], 121 | "time": "2015-10-15 22:28:00" 122 | }, 123 | { 124 | "name": "guzzlehttp/psr7", 125 | "version": "1.2.1", 126 | "source": { 127 | "type": "git", 128 | "url": "https://github.com/guzzle/psr7.git", 129 | "reference": "4d0bdbe1206df7440219ce14c972aa57cc5e4982" 130 | }, 131 | "dist": { 132 | "type": "zip", 133 | "url": "https://api.github.com/repos/guzzle/psr7/zipball/4d0bdbe1206df7440219ce14c972aa57cc5e4982", 134 | "reference": "4d0bdbe1206df7440219ce14c972aa57cc5e4982", 135 | "shasum": "" 136 | }, 137 | "require": { 138 | "php": ">=5.4.0", 139 | "psr/http-message": "~1.0" 140 | }, 141 | "provide": { 142 | "psr/http-message-implementation": "1.0" 143 | }, 144 | "require-dev": { 145 | "phpunit/phpunit": "~4.0" 146 | }, 147 | "type": "library", 148 | "extra": { 149 | "branch-alias": { 150 | "dev-master": "1.0-dev" 151 | } 152 | }, 153 | "autoload": { 154 | "psr-4": { 155 | "GuzzleHttp\\Psr7\\": "src/" 156 | }, 157 | "files": [ 158 | "src/functions_include.php" 159 | ] 160 | }, 161 | "notification-url": "https://packagist.org/downloads/", 162 | "license": [ 163 | "MIT" 164 | ], 165 | "authors": [ 166 | { 167 | "name": "Michael Dowling", 168 | "email": "mtdowling@gmail.com", 169 | "homepage": "https://github.com/mtdowling" 170 | } 171 | ], 172 | "description": "PSR-7 message implementation", 173 | "keywords": [ 174 | "http", 175 | "message", 176 | "stream", 177 | "uri" 178 | ], 179 | "time": "2015-11-03 01:34:55" 180 | }, 181 | { 182 | "name": "psr/http-message", 183 | "version": "1.0", 184 | "source": { 185 | "type": "git", 186 | "url": "https://github.com/php-fig/http-message.git", 187 | "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298" 188 | }, 189 | "dist": { 190 | "type": "zip", 191 | "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", 192 | "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", 193 | "shasum": "" 194 | }, 195 | "require": { 196 | "php": ">=5.3.0" 197 | }, 198 | "type": "library", 199 | "extra": { 200 | "branch-alias": { 201 | "dev-master": "1.0.x-dev" 202 | } 203 | }, 204 | "autoload": { 205 | "psr-4": { 206 | "Psr\\Http\\Message\\": "src/" 207 | } 208 | }, 209 | "notification-url": "https://packagist.org/downloads/", 210 | "license": [ 211 | "MIT" 212 | ], 213 | "authors": [ 214 | { 215 | "name": "PHP-FIG", 216 | "homepage": "http://www.php-fig.org/" 217 | } 218 | ], 219 | "description": "Common interface for HTTP messages", 220 | "keywords": [ 221 | "http", 222 | "http-message", 223 | "psr", 224 | "psr-7", 225 | "request", 226 | "response" 227 | ], 228 | "time": "2015-05-04 20:22:00" 229 | }, 230 | { 231 | "name": "ramsey/uuid", 232 | "version": "3.0.1", 233 | "source": { 234 | "type": "git", 235 | "url": "https://github.com/ramsey/uuid.git", 236 | "reference": "3c84b9e2965a5fa666dec8617a3a66a8179c6ca8" 237 | }, 238 | "dist": { 239 | "type": "zip", 240 | "url": "https://api.github.com/repos/ramsey/uuid/zipball/3c84b9e2965a5fa666dec8617a3a66a8179c6ca8", 241 | "reference": "3c84b9e2965a5fa666dec8617a3a66a8179c6ca8", 242 | "shasum": "" 243 | }, 244 | "require": { 245 | "php": ">=5.4" 246 | }, 247 | "replace": { 248 | "rhumsaa/uuid": "self.version" 249 | }, 250 | "require-dev": { 251 | "apigen/apigen": "^4.1", 252 | "ircmaxell/random-lib": "^1.1", 253 | "jakub-onderka/php-parallel-lint": "^0.9.0", 254 | "moontoast/math": "^1.1", 255 | "phpunit/phpunit": "^4.7", 256 | "satooshi/php-coveralls": "^0.6.1", 257 | "squizlabs/php_codesniffer": "^2.3" 258 | }, 259 | "suggest": { 260 | "ext-uuid": "Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator", 261 | "ircmaxell/random-lib": "Provides RandomLib for use with the RandomLibAdapter", 262 | "moontoast/math": "Provides support for converting UUID to 128-bit integer (in string form).", 263 | "ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid", 264 | "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." 265 | }, 266 | "type": "library", 267 | "autoload": { 268 | "psr-4": { 269 | "Ramsey\\Uuid\\": "src/" 270 | } 271 | }, 272 | "notification-url": "https://packagist.org/downloads/", 273 | "license": [ 274 | "MIT" 275 | ], 276 | "authors": [ 277 | { 278 | "name": "Marijn Huizendveld", 279 | "email": "marijn.huizendveld@gmail.com" 280 | }, 281 | { 282 | "name": "Thibaud Fabre", 283 | "email": "thibaud@aztech.io" 284 | }, 285 | { 286 | "name": "Ben Ramsey", 287 | "email": "ben@benramsey.com", 288 | "homepage": "https://benramsey.com" 289 | } 290 | ], 291 | "description": "Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).", 292 | "homepage": "https://github.com/ramsey/uuid", 293 | "keywords": [ 294 | "guid", 295 | "identifier", 296 | "uuid" 297 | ], 298 | "time": "2015-10-21 16:27:25" 299 | } 300 | ], 301 | "packages-dev": [], 302 | "aliases": [], 303 | "minimum-stability": "stable", 304 | "stability-flags": [], 305 | "prefer-stable": false, 306 | "prefer-lowest": false, 307 | "platform": [], 308 | "platform-dev": [] 309 | } 310 | -------------------------------------------------------------------------------- /03-creating-new-items/create.php: -------------------------------------------------------------------------------- 1 | 'https://api.gathercontent.com', 13 | 'headers' => [ 14 | 'Accept' => 'application/vnd.gathercontent.v0.5+json' 15 | ], 16 | 'auth' => [ 17 | $username, 18 | $apikey 19 | ] 20 | ]); 21 | 22 | // Item Structure 23 | $item = [ 24 | (object) [ 25 | 'label' => "Content", 26 | 'name' => Uuid::uuid4()->toString(), 27 | 'hidden' => false, 28 | 'elements' => [ 29 | (object) [ 30 | 'type' => "text", 31 | 'name' => Uuid::uuid4()->toString(), 32 | 'required' => true, 33 | 'label' => "Title", 34 | 'value' => "", 35 | 'microcopy' => "", 36 | 'limit_type' => "chars", 37 | 'limit' => 0, 38 | 'plain_text' => false 39 | ], 40 | (object) [ 41 | 'type' => "text", 42 | 'name' => Uuid::uuid4()->toString(), 43 | 'required' => true, 44 | 'label' => "Main content", 45 | 'value' => "", 46 | 'microcopy' => "", 47 | 'limit_type' => "words", 48 | 'limit' => 0, 49 | 'plain_text' => true 50 | ], 51 | ] 52 | ] 53 | ]; 54 | 55 | // Make API call 56 | $client->post('/items', [ 57 | 'form_params' => [ 58 | 'project_id' => $projectId, 59 | 'name' => 'New Item', 60 | 'config' => base64_encode(json_encode($item)) 61 | ] 62 | ]); 63 | -------------------------------------------------------------------------------- /04-import-from-sitemap/.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | credentials 3 | key -------------------------------------------------------------------------------- /04-import-from-sitemap/README.md: -------------------------------------------------------------------------------- 1 | # Import existing text content from the web into GatherContent 2 | 3 | ## Description 4 | 5 | This is an example interactive command line application, which takes a url to a `sitemap.xml` file, creates a list of web pages on that website, then parses the text from a chosen CSS selector on each web page and creates a corresponding item in GatherContent. 6 | 7 | ## Requirements 8 | 9 | * PHP 5.5+ 10 | * Composer (PHP package management tool) 11 | 12 | ## Installation 13 | 14 | Clone this package from GitHub 15 | 16 | ```bash 17 | $ git clone https://github.com/gathercontent/api-examples.git 18 | ``` 19 | 20 | Move into this project directory 21 | 22 | ```bash 23 | $ cd 04-import-from-sitemap 24 | ``` 25 | 26 | Install the package dependencies 27 | 28 | ```bash 29 | $ composer install 30 | ``` 31 | 32 | ## How to use the application 33 | 34 | Execute the application with 35 | 36 | ```bash 37 | $ bin/scrape 38 | ``` 39 | 40 | You will be prompted for a username and API key (found in your personal settings). 41 | 42 | If you are a member of multiple accounts on GatherContent you will be asked to choose which account you are importing to. 43 | 44 | You can then choose to create a new project, or import content into an existing project. 45 | 46 | Give the application a link to your sitemap.xml file, e.g. http://yourwebsite.com/sitemap.xml 47 | 48 | You should see a number of pages that will be scraped. 49 | 50 | Next choose a CSS selector - e.g. 'article' or css class '.content', '#main-content' to denote which block of content you want imported. 51 | 52 | Then confirm and watch the content be pulled and posted back to GatherContent through the public API. 53 | 54 | ## FAQ 55 | 56 | ### Why are HTML tags not imported? 57 | 58 | If you look at [line 14 of ContentScraper](https://github.com/gathercontent/api-examples/blob/82dda9600e74ab549c5923838d2fca0f39bc74c1/04-import-from-sitemap/src/ContentScraper.php#L14) you will see we are only scraping the _text_ of the element, not the _HTML_. You can change this to `return $filtered->html();` instead if you wish to import HTML. 59 | Note that some uncommon HTML tags may still not be available, and you will have to contact support@gathercontent.com to add these to your project. 60 | 61 | ### How can I avoid all my content being imported as one blob? 62 | 63 | The `ImportCommand` is configured to only import two fields - the page `` and a dynamically scraped element from the [$cssSelector submitted by the user](https://github.com/gathercontent/api-examples/blob/82dda9600e74ab549c5923838d2fca0f39bc74c1/04-import-from-sitemap/src/ImportCommand.php#L104) as you can [see here](https://github.com/gathercontent/api-examples/blob/82dda9600e74ab549c5923838d2fca0f39bc74c1/04-import-from-sitemap/src/ImportCommand.php#L118). 64 | 65 | If you have a consistent template that you are importing from, you could edit this file and change the array. For example, say you had a `<title>`, `<h1>`, `<div id="main">`, and `<p class="call-to-action">` on every field that you wanted to import - you can just override the second argument given to `ContentToFieldMaper->mapContentToFields()` like so: 66 | 67 | ``` 68 | $map = [ 69 | 'Page Title' => 'title', 70 | 'Heading' => 'h1', 71 | 'Main Content' => 'div#main', 72 | 'Call to Action' => 'p.call-to-action' 73 | ]; 74 | 75 | $contentToFieldMapper->mapToFields($html, $map); 76 | ``` 77 | 78 | ## Running tests 79 | 80 | To run the phpspec test suite run 81 | 82 | ```bash 83 | $ vendor/bin/phpspec run 84 | ``` 85 | 86 | -------------------------------------------------------------------------------- /04-import-from-sitemap/bin/scrape: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | <?php 3 | 4 | require_once __DIR__ . '/../vendor/autoload.php'; 5 | 6 | (new ScrapeApplication())->run(); 7 | -------------------------------------------------------------------------------- /04-import-from-sitemap/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "autoload": { 3 | "psr-4": { 4 | "": "src" 5 | } 6 | }, 7 | "require-dev": { 8 | "phpspec/phpspec": "^2.5" 9 | }, 10 | "require": { 11 | "symfony/dom-crawler": "^3.1", 12 | "symfony/css-selector": "^3.1", 13 | "symfony/console": "^3.1", 14 | "guzzlehttp/guzzle": "^6.2" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /04-import-from-sitemap/composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "a741fab124069a5f11af55e52ff19bec", 8 | "content-hash": "bbd4a8dd13f0ba397248c9cb2a2c1df7", 9 | "packages": [ 10 | { 11 | "name": "guzzlehttp/guzzle", 12 | "version": "6.2.0", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/guzzle/guzzle.git", 16 | "reference": "d094e337976dff9d8e2424e8485872194e768662" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662", 21 | "reference": "d094e337976dff9d8e2424e8485872194e768662", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "guzzlehttp/promises": "~1.0", 26 | "guzzlehttp/psr7": "~1.1", 27 | "php": ">=5.5.0" 28 | }, 29 | "require-dev": { 30 | "ext-curl": "*", 31 | "phpunit/phpunit": "~4.0", 32 | "psr/log": "~1.0" 33 | }, 34 | "type": "library", 35 | "extra": { 36 | "branch-alias": { 37 | "dev-master": "6.2-dev" 38 | } 39 | }, 40 | "autoload": { 41 | "files": [ 42 | "src/functions_include.php" 43 | ], 44 | "psr-4": { 45 | "GuzzleHttp\\": "src/" 46 | } 47 | }, 48 | "notification-url": "https://packagist.org/downloads/", 49 | "license": [ 50 | "MIT" 51 | ], 52 | "authors": [ 53 | { 54 | "name": "Michael Dowling", 55 | "email": "mtdowling@gmail.com", 56 | "homepage": "https://github.com/mtdowling" 57 | } 58 | ], 59 | "description": "Guzzle is a PHP HTTP client library", 60 | "homepage": "http://guzzlephp.org/", 61 | "keywords": [ 62 | "client", 63 | "curl", 64 | "framework", 65 | "http", 66 | "http client", 67 | "rest", 68 | "web service" 69 | ], 70 | "time": "2016-03-21 20:02:09" 71 | }, 72 | { 73 | "name": "guzzlehttp/promises", 74 | "version": "1.2.0", 75 | "source": { 76 | "type": "git", 77 | "url": "https://github.com/guzzle/promises.git", 78 | "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579" 79 | }, 80 | "dist": { 81 | "type": "zip", 82 | "url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579", 83 | "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579", 84 | "shasum": "" 85 | }, 86 | "require": { 87 | "php": ">=5.5.0" 88 | }, 89 | "require-dev": { 90 | "phpunit/phpunit": "~4.0" 91 | }, 92 | "type": "library", 93 | "extra": { 94 | "branch-alias": { 95 | "dev-master": "1.0-dev" 96 | } 97 | }, 98 | "autoload": { 99 | "psr-4": { 100 | "GuzzleHttp\\Promise\\": "src/" 101 | }, 102 | "files": [ 103 | "src/functions_include.php" 104 | ] 105 | }, 106 | "notification-url": "https://packagist.org/downloads/", 107 | "license": [ 108 | "MIT" 109 | ], 110 | "authors": [ 111 | { 112 | "name": "Michael Dowling", 113 | "email": "mtdowling@gmail.com", 114 | "homepage": "https://github.com/mtdowling" 115 | } 116 | ], 117 | "description": "Guzzle promises library", 118 | "keywords": [ 119 | "promise" 120 | ], 121 | "time": "2016-05-18 16:56:05" 122 | }, 123 | { 124 | "name": "guzzlehttp/psr7", 125 | "version": "1.3.1", 126 | "source": { 127 | "type": "git", 128 | "url": "https://github.com/guzzle/psr7.git", 129 | "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b" 130 | }, 131 | "dist": { 132 | "type": "zip", 133 | "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", 134 | "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", 135 | "shasum": "" 136 | }, 137 | "require": { 138 | "php": ">=5.4.0", 139 | "psr/http-message": "~1.0" 140 | }, 141 | "provide": { 142 | "psr/http-message-implementation": "1.0" 143 | }, 144 | "require-dev": { 145 | "phpunit/phpunit": "~4.0" 146 | }, 147 | "type": "library", 148 | "extra": { 149 | "branch-alias": { 150 | "dev-master": "1.4-dev" 151 | } 152 | }, 153 | "autoload": { 154 | "psr-4": { 155 | "GuzzleHttp\\Psr7\\": "src/" 156 | }, 157 | "files": [ 158 | "src/functions_include.php" 159 | ] 160 | }, 161 | "notification-url": "https://packagist.org/downloads/", 162 | "license": [ 163 | "MIT" 164 | ], 165 | "authors": [ 166 | { 167 | "name": "Michael Dowling", 168 | "email": "mtdowling@gmail.com", 169 | "homepage": "https://github.com/mtdowling" 170 | } 171 | ], 172 | "description": "PSR-7 message implementation", 173 | "keywords": [ 174 | "http", 175 | "message", 176 | "stream", 177 | "uri" 178 | ], 179 | "time": "2016-06-24 23:00:38" 180 | }, 181 | { 182 | "name": "psr/http-message", 183 | "version": "1.0", 184 | "source": { 185 | "type": "git", 186 | "url": "https://github.com/php-fig/http-message.git", 187 | "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298" 188 | }, 189 | "dist": { 190 | "type": "zip", 191 | "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", 192 | "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", 193 | "shasum": "" 194 | }, 195 | "require": { 196 | "php": ">=5.3.0" 197 | }, 198 | "type": "library", 199 | "extra": { 200 | "branch-alias": { 201 | "dev-master": "1.0.x-dev" 202 | } 203 | }, 204 | "autoload": { 205 | "psr-4": { 206 | "Psr\\Http\\Message\\": "src/" 207 | } 208 | }, 209 | "notification-url": "https://packagist.org/downloads/", 210 | "license": [ 211 | "MIT" 212 | ], 213 | "authors": [ 214 | { 215 | "name": "PHP-FIG", 216 | "homepage": "http://www.php-fig.org/" 217 | } 218 | ], 219 | "description": "Common interface for HTTP messages", 220 | "keywords": [ 221 | "http", 222 | "http-message", 223 | "psr", 224 | "psr-7", 225 | "request", 226 | "response" 227 | ], 228 | "time": "2015-05-04 20:22:00" 229 | }, 230 | { 231 | "name": "symfony/console", 232 | "version": "v3.1.2", 233 | "source": { 234 | "type": "git", 235 | "url": "https://github.com/symfony/console.git", 236 | "reference": "747154aa69b0f83cd02fc9aa554836dee417631a" 237 | }, 238 | "dist": { 239 | "type": "zip", 240 | "url": "https://api.github.com/repos/symfony/console/zipball/747154aa69b0f83cd02fc9aa554836dee417631a", 241 | "reference": "747154aa69b0f83cd02fc9aa554836dee417631a", 242 | "shasum": "" 243 | }, 244 | "require": { 245 | "php": ">=5.5.9", 246 | "symfony/polyfill-mbstring": "~1.0" 247 | }, 248 | "require-dev": { 249 | "psr/log": "~1.0", 250 | "symfony/event-dispatcher": "~2.8|~3.0", 251 | "symfony/process": "~2.8|~3.0" 252 | }, 253 | "suggest": { 254 | "psr/log": "For using the console logger", 255 | "symfony/event-dispatcher": "", 256 | "symfony/process": "" 257 | }, 258 | "type": "library", 259 | "extra": { 260 | "branch-alias": { 261 | "dev-master": "3.1-dev" 262 | } 263 | }, 264 | "autoload": { 265 | "psr-4": { 266 | "Symfony\\Component\\Console\\": "" 267 | }, 268 | "exclude-from-classmap": [ 269 | "/Tests/" 270 | ] 271 | }, 272 | "notification-url": "https://packagist.org/downloads/", 273 | "license": [ 274 | "MIT" 275 | ], 276 | "authors": [ 277 | { 278 | "name": "Fabien Potencier", 279 | "email": "fabien@symfony.com" 280 | }, 281 | { 282 | "name": "Symfony Community", 283 | "homepage": "https://symfony.com/contributors" 284 | } 285 | ], 286 | "description": "Symfony Console Component", 287 | "homepage": "https://symfony.com", 288 | "time": "2016-06-29 07:02:31" 289 | }, 290 | { 291 | "name": "symfony/css-selector", 292 | "version": "v3.1.2", 293 | "source": { 294 | "type": "git", 295 | "url": "https://github.com/symfony/css-selector.git", 296 | "reference": "2851e1932d77ce727776154d659b232d061e816a" 297 | }, 298 | "dist": { 299 | "type": "zip", 300 | "url": "https://api.github.com/repos/symfony/css-selector/zipball/2851e1932d77ce727776154d659b232d061e816a", 301 | "reference": "2851e1932d77ce727776154d659b232d061e816a", 302 | "shasum": "" 303 | }, 304 | "require": { 305 | "php": ">=5.5.9" 306 | }, 307 | "type": "library", 308 | "extra": { 309 | "branch-alias": { 310 | "dev-master": "3.1-dev" 311 | } 312 | }, 313 | "autoload": { 314 | "psr-4": { 315 | "Symfony\\Component\\CssSelector\\": "" 316 | }, 317 | "exclude-from-classmap": [ 318 | "/Tests/" 319 | ] 320 | }, 321 | "notification-url": "https://packagist.org/downloads/", 322 | "license": [ 323 | "MIT" 324 | ], 325 | "authors": [ 326 | { 327 | "name": "Jean-François Simon", 328 | "email": "jeanfrancois.simon@sensiolabs.com" 329 | }, 330 | { 331 | "name": "Fabien Potencier", 332 | "email": "fabien@symfony.com" 333 | }, 334 | { 335 | "name": "Symfony Community", 336 | "homepage": "https://symfony.com/contributors" 337 | } 338 | ], 339 | "description": "Symfony CssSelector Component", 340 | "homepage": "https://symfony.com", 341 | "time": "2016-06-29 05:41:56" 342 | }, 343 | { 344 | "name": "symfony/dom-crawler", 345 | "version": "v3.1.2", 346 | "source": { 347 | "type": "git", 348 | "url": "https://github.com/symfony/dom-crawler.git", 349 | "reference": "99ec4a23330fcd0c8667095f3ef7aa204ffd9dc0" 350 | }, 351 | "dist": { 352 | "type": "zip", 353 | "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/99ec4a23330fcd0c8667095f3ef7aa204ffd9dc0", 354 | "reference": "99ec4a23330fcd0c8667095f3ef7aa204ffd9dc0", 355 | "shasum": "" 356 | }, 357 | "require": { 358 | "php": ">=5.5.9", 359 | "symfony/polyfill-mbstring": "~1.0" 360 | }, 361 | "require-dev": { 362 | "symfony/css-selector": "~2.8|~3.0" 363 | }, 364 | "suggest": { 365 | "symfony/css-selector": "" 366 | }, 367 | "type": "library", 368 | "extra": { 369 | "branch-alias": { 370 | "dev-master": "3.1-dev" 371 | } 372 | }, 373 | "autoload": { 374 | "psr-4": { 375 | "Symfony\\Component\\DomCrawler\\": "" 376 | }, 377 | "exclude-from-classmap": [ 378 | "/Tests/" 379 | ] 380 | }, 381 | "notification-url": "https://packagist.org/downloads/", 382 | "license": [ 383 | "MIT" 384 | ], 385 | "authors": [ 386 | { 387 | "name": "Fabien Potencier", 388 | "email": "fabien@symfony.com" 389 | }, 390 | { 391 | "name": "Symfony Community", 392 | "homepage": "https://symfony.com/contributors" 393 | } 394 | ], 395 | "description": "Symfony DomCrawler Component", 396 | "homepage": "https://symfony.com", 397 | "time": "2016-06-29 05:41:56" 398 | }, 399 | { 400 | "name": "symfony/polyfill-mbstring", 401 | "version": "v1.2.0", 402 | "source": { 403 | "type": "git", 404 | "url": "https://github.com/symfony/polyfill-mbstring.git", 405 | "reference": "dff51f72b0706335131b00a7f49606168c582594" 406 | }, 407 | "dist": { 408 | "type": "zip", 409 | "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594", 410 | "reference": "dff51f72b0706335131b00a7f49606168c582594", 411 | "shasum": "" 412 | }, 413 | "require": { 414 | "php": ">=5.3.3" 415 | }, 416 | "suggest": { 417 | "ext-mbstring": "For best performance" 418 | }, 419 | "type": "library", 420 | "extra": { 421 | "branch-alias": { 422 | "dev-master": "1.2-dev" 423 | } 424 | }, 425 | "autoload": { 426 | "psr-4": { 427 | "Symfony\\Polyfill\\Mbstring\\": "" 428 | }, 429 | "files": [ 430 | "bootstrap.php" 431 | ] 432 | }, 433 | "notification-url": "https://packagist.org/downloads/", 434 | "license": [ 435 | "MIT" 436 | ], 437 | "authors": [ 438 | { 439 | "name": "Nicolas Grekas", 440 | "email": "p@tchwork.com" 441 | }, 442 | { 443 | "name": "Symfony Community", 444 | "homepage": "https://symfony.com/contributors" 445 | } 446 | ], 447 | "description": "Symfony polyfill for the Mbstring extension", 448 | "homepage": "https://symfony.com", 449 | "keywords": [ 450 | "compatibility", 451 | "mbstring", 452 | "polyfill", 453 | "portable", 454 | "shim" 455 | ], 456 | "time": "2016-05-18 14:26:46" 457 | } 458 | ], 459 | "packages-dev": [ 460 | { 461 | "name": "doctrine/instantiator", 462 | "version": "1.0.5", 463 | "source": { 464 | "type": "git", 465 | "url": "https://github.com/doctrine/instantiator.git", 466 | "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" 467 | }, 468 | "dist": { 469 | "type": "zip", 470 | "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", 471 | "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", 472 | "shasum": "" 473 | }, 474 | "require": { 475 | "php": ">=5.3,<8.0-DEV" 476 | }, 477 | "require-dev": { 478 | "athletic/athletic": "~0.1.8", 479 | "ext-pdo": "*", 480 | "ext-phar": "*", 481 | "phpunit/phpunit": "~4.0", 482 | "squizlabs/php_codesniffer": "~2.0" 483 | }, 484 | "type": "library", 485 | "extra": { 486 | "branch-alias": { 487 | "dev-master": "1.0.x-dev" 488 | } 489 | }, 490 | "autoload": { 491 | "psr-4": { 492 | "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" 493 | } 494 | }, 495 | "notification-url": "https://packagist.org/downloads/", 496 | "license": [ 497 | "MIT" 498 | ], 499 | "authors": [ 500 | { 501 | "name": "Marco Pivetta", 502 | "email": "ocramius@gmail.com", 503 | "homepage": "http://ocramius.github.com/" 504 | } 505 | ], 506 | "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", 507 | "homepage": "https://github.com/doctrine/instantiator", 508 | "keywords": [ 509 | "constructor", 510 | "instantiate" 511 | ], 512 | "time": "2015-06-14 21:17:01" 513 | }, 514 | { 515 | "name": "phpdocumentor/reflection-common", 516 | "version": "1.0", 517 | "source": { 518 | "type": "git", 519 | "url": "https://github.com/phpDocumentor/ReflectionCommon.git", 520 | "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" 521 | }, 522 | "dist": { 523 | "type": "zip", 524 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", 525 | "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", 526 | "shasum": "" 527 | }, 528 | "require": { 529 | "php": ">=5.5" 530 | }, 531 | "require-dev": { 532 | "phpunit/phpunit": "^4.6" 533 | }, 534 | "type": "library", 535 | "extra": { 536 | "branch-alias": { 537 | "dev-master": "1.0.x-dev" 538 | } 539 | }, 540 | "autoload": { 541 | "psr-4": { 542 | "phpDocumentor\\Reflection\\": [ 543 | "src" 544 | ] 545 | } 546 | }, 547 | "notification-url": "https://packagist.org/downloads/", 548 | "license": [ 549 | "MIT" 550 | ], 551 | "authors": [ 552 | { 553 | "name": "Jaap van Otterdijk", 554 | "email": "opensource@ijaap.nl" 555 | } 556 | ], 557 | "description": "Common reflection classes used by phpdocumentor to reflect the code structure", 558 | "homepage": "http://www.phpdoc.org", 559 | "keywords": [ 560 | "FQSEN", 561 | "phpDocumentor", 562 | "phpdoc", 563 | "reflection", 564 | "static analysis" 565 | ], 566 | "time": "2015-12-27 11:43:31" 567 | }, 568 | { 569 | "name": "phpdocumentor/reflection-docblock", 570 | "version": "3.1.0", 571 | "source": { 572 | "type": "git", 573 | "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", 574 | "reference": "9270140b940ff02e58ec577c237274e92cd40cdd" 575 | }, 576 | "dist": { 577 | "type": "zip", 578 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9270140b940ff02e58ec577c237274e92cd40cdd", 579 | "reference": "9270140b940ff02e58ec577c237274e92cd40cdd", 580 | "shasum": "" 581 | }, 582 | "require": { 583 | "php": ">=5.5", 584 | "phpdocumentor/reflection-common": "^1.0@dev", 585 | "phpdocumentor/type-resolver": "^0.2.0", 586 | "webmozart/assert": "^1.0" 587 | }, 588 | "require-dev": { 589 | "mockery/mockery": "^0.9.4", 590 | "phpunit/phpunit": "^4.4" 591 | }, 592 | "type": "library", 593 | "autoload": { 594 | "psr-4": { 595 | "phpDocumentor\\Reflection\\": [ 596 | "src/" 597 | ] 598 | } 599 | }, 600 | "notification-url": "https://packagist.org/downloads/", 601 | "license": [ 602 | "MIT" 603 | ], 604 | "authors": [ 605 | { 606 | "name": "Mike van Riel", 607 | "email": "me@mikevanriel.com" 608 | } 609 | ], 610 | "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", 611 | "time": "2016-06-10 09:48:41" 612 | }, 613 | { 614 | "name": "phpdocumentor/type-resolver", 615 | "version": "0.2", 616 | "source": { 617 | "type": "git", 618 | "url": "https://github.com/phpDocumentor/TypeResolver.git", 619 | "reference": "b39c7a5b194f9ed7bd0dd345c751007a41862443" 620 | }, 621 | "dist": { 622 | "type": "zip", 623 | "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/b39c7a5b194f9ed7bd0dd345c751007a41862443", 624 | "reference": "b39c7a5b194f9ed7bd0dd345c751007a41862443", 625 | "shasum": "" 626 | }, 627 | "require": { 628 | "php": ">=5.5", 629 | "phpdocumentor/reflection-common": "^1.0" 630 | }, 631 | "require-dev": { 632 | "mockery/mockery": "^0.9.4", 633 | "phpunit/phpunit": "^5.2||^4.8.24" 634 | }, 635 | "type": "library", 636 | "extra": { 637 | "branch-alias": { 638 | "dev-master": "1.0.x-dev" 639 | } 640 | }, 641 | "autoload": { 642 | "psr-4": { 643 | "phpDocumentor\\Reflection\\": [ 644 | "src/" 645 | ] 646 | } 647 | }, 648 | "notification-url": "https://packagist.org/downloads/", 649 | "license": [ 650 | "MIT" 651 | ], 652 | "authors": [ 653 | { 654 | "name": "Mike van Riel", 655 | "email": "me@mikevanriel.com" 656 | } 657 | ], 658 | "time": "2016-06-10 07:14:17" 659 | }, 660 | { 661 | "name": "phpspec/php-diff", 662 | "version": "v1.0.2", 663 | "source": { 664 | "type": "git", 665 | "url": "https://github.com/phpspec/php-diff.git", 666 | "reference": "30e103d19519fe678ae64a60d77884ef3d71b28a" 667 | }, 668 | "dist": { 669 | "type": "zip", 670 | "url": "https://api.github.com/repos/phpspec/php-diff/zipball/30e103d19519fe678ae64a60d77884ef3d71b28a", 671 | "reference": "30e103d19519fe678ae64a60d77884ef3d71b28a", 672 | "shasum": "" 673 | }, 674 | "type": "library", 675 | "autoload": { 676 | "psr-0": { 677 | "Diff": "lib/" 678 | } 679 | }, 680 | "notification-url": "https://packagist.org/downloads/", 681 | "license": [ 682 | "BSD-3-Clause" 683 | ], 684 | "authors": [ 685 | { 686 | "name": "Chris Boulton", 687 | "homepage": "http://github.com/chrisboulton", 688 | "role": "Original developer" 689 | } 690 | ], 691 | "description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).", 692 | "time": "2013-11-01 13:02:21" 693 | }, 694 | { 695 | "name": "phpspec/phpspec", 696 | "version": "2.5.0", 697 | "source": { 698 | "type": "git", 699 | "url": "https://github.com/phpspec/phpspec.git", 700 | "reference": "385ecb015e97c13818074f1517928b24d4a26067" 701 | }, 702 | "dist": { 703 | "type": "zip", 704 | "url": "https://api.github.com/repos/phpspec/phpspec/zipball/385ecb015e97c13818074f1517928b24d4a26067", 705 | "reference": "385ecb015e97c13818074f1517928b24d4a26067", 706 | "shasum": "" 707 | }, 708 | "require": { 709 | "doctrine/instantiator": "^1.0.1", 710 | "ext-tokenizer": "*", 711 | "php": ">=5.3.3", 712 | "phpspec/php-diff": "~1.0.0", 713 | "phpspec/prophecy": "~1.4", 714 | "sebastian/exporter": "~1.0", 715 | "symfony/console": "~2.3|~3.0", 716 | "symfony/event-dispatcher": "~2.1|~3.0", 717 | "symfony/finder": "~2.1|~3.0", 718 | "symfony/process": "^2.6|~3.0", 719 | "symfony/yaml": "~2.1|~3.0" 720 | }, 721 | "require-dev": { 722 | "behat/behat": "^3.0.11", 723 | "bossa/phpspec2-expect": "~1.0", 724 | "phpunit/phpunit": "~4.4", 725 | "symfony/filesystem": "~2.1|~3.0" 726 | }, 727 | "suggest": { 728 | "phpspec/nyan-formatters": "~1.0 – Adds Nyan formatters" 729 | }, 730 | "bin": [ 731 | "bin/phpspec" 732 | ], 733 | "type": "library", 734 | "extra": { 735 | "branch-alias": { 736 | "dev-master": "2.2.x-dev" 737 | } 738 | }, 739 | "autoload": { 740 | "psr-0": { 741 | "PhpSpec": "src/" 742 | } 743 | }, 744 | "notification-url": "https://packagist.org/downloads/", 745 | "license": [ 746 | "MIT" 747 | ], 748 | "authors": [ 749 | { 750 | "name": "Konstantin Kudryashov", 751 | "email": "ever.zet@gmail.com", 752 | "homepage": "http://everzet.com" 753 | }, 754 | { 755 | "name": "Marcello Duarte", 756 | "homepage": "http://marcelloduarte.net/" 757 | } 758 | ], 759 | "description": "Specification-oriented BDD framework for PHP 5.3+", 760 | "homepage": "http://phpspec.net/", 761 | "keywords": [ 762 | "BDD", 763 | "SpecBDD", 764 | "TDD", 765 | "spec", 766 | "specification", 767 | "testing", 768 | "tests" 769 | ], 770 | "time": "2016-03-20 20:34:32" 771 | }, 772 | { 773 | "name": "phpspec/prophecy", 774 | "version": "v1.6.1", 775 | "source": { 776 | "type": "git", 777 | "url": "https://github.com/phpspec/prophecy.git", 778 | "reference": "58a8137754bc24b25740d4281399a4a3596058e0" 779 | }, 780 | "dist": { 781 | "type": "zip", 782 | "url": "https://api.github.com/repos/phpspec/prophecy/zipball/58a8137754bc24b25740d4281399a4a3596058e0", 783 | "reference": "58a8137754bc24b25740d4281399a4a3596058e0", 784 | "shasum": "" 785 | }, 786 | "require": { 787 | "doctrine/instantiator": "^1.0.2", 788 | "php": "^5.3|^7.0", 789 | "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", 790 | "sebastian/comparator": "^1.1", 791 | "sebastian/recursion-context": "^1.0" 792 | }, 793 | "require-dev": { 794 | "phpspec/phpspec": "^2.0" 795 | }, 796 | "type": "library", 797 | "extra": { 798 | "branch-alias": { 799 | "dev-master": "1.6.x-dev" 800 | } 801 | }, 802 | "autoload": { 803 | "psr-0": { 804 | "Prophecy\\": "src/" 805 | } 806 | }, 807 | "notification-url": "https://packagist.org/downloads/", 808 | "license": [ 809 | "MIT" 810 | ], 811 | "authors": [ 812 | { 813 | "name": "Konstantin Kudryashov", 814 | "email": "ever.zet@gmail.com", 815 | "homepage": "http://everzet.com" 816 | }, 817 | { 818 | "name": "Marcello Duarte", 819 | "email": "marcello.duarte@gmail.com" 820 | } 821 | ], 822 | "description": "Highly opinionated mocking framework for PHP 5.3+", 823 | "homepage": "https://github.com/phpspec/prophecy", 824 | "keywords": [ 825 | "Double", 826 | "Dummy", 827 | "fake", 828 | "mock", 829 | "spy", 830 | "stub" 831 | ], 832 | "time": "2016-06-07 08:13:47" 833 | }, 834 | { 835 | "name": "sebastian/comparator", 836 | "version": "1.2.0", 837 | "source": { 838 | "type": "git", 839 | "url": "https://github.com/sebastianbergmann/comparator.git", 840 | "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" 841 | }, 842 | "dist": { 843 | "type": "zip", 844 | "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", 845 | "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", 846 | "shasum": "" 847 | }, 848 | "require": { 849 | "php": ">=5.3.3", 850 | "sebastian/diff": "~1.2", 851 | "sebastian/exporter": "~1.2" 852 | }, 853 | "require-dev": { 854 | "phpunit/phpunit": "~4.4" 855 | }, 856 | "type": "library", 857 | "extra": { 858 | "branch-alias": { 859 | "dev-master": "1.2.x-dev" 860 | } 861 | }, 862 | "autoload": { 863 | "classmap": [ 864 | "src/" 865 | ] 866 | }, 867 | "notification-url": "https://packagist.org/downloads/", 868 | "license": [ 869 | "BSD-3-Clause" 870 | ], 871 | "authors": [ 872 | { 873 | "name": "Jeff Welch", 874 | "email": "whatthejeff@gmail.com" 875 | }, 876 | { 877 | "name": "Volker Dusch", 878 | "email": "github@wallbash.com" 879 | }, 880 | { 881 | "name": "Bernhard Schussek", 882 | "email": "bschussek@2bepublished.at" 883 | }, 884 | { 885 | "name": "Sebastian Bergmann", 886 | "email": "sebastian@phpunit.de" 887 | } 888 | ], 889 | "description": "Provides the functionality to compare PHP values for equality", 890 | "homepage": "http://www.github.com/sebastianbergmann/comparator", 891 | "keywords": [ 892 | "comparator", 893 | "compare", 894 | "equality" 895 | ], 896 | "time": "2015-07-26 15:48:44" 897 | }, 898 | { 899 | "name": "sebastian/diff", 900 | "version": "1.4.1", 901 | "source": { 902 | "type": "git", 903 | "url": "https://github.com/sebastianbergmann/diff.git", 904 | "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" 905 | }, 906 | "dist": { 907 | "type": "zip", 908 | "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", 909 | "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", 910 | "shasum": "" 911 | }, 912 | "require": { 913 | "php": ">=5.3.3" 914 | }, 915 | "require-dev": { 916 | "phpunit/phpunit": "~4.8" 917 | }, 918 | "type": "library", 919 | "extra": { 920 | "branch-alias": { 921 | "dev-master": "1.4-dev" 922 | } 923 | }, 924 | "autoload": { 925 | "classmap": [ 926 | "src/" 927 | ] 928 | }, 929 | "notification-url": "https://packagist.org/downloads/", 930 | "license": [ 931 | "BSD-3-Clause" 932 | ], 933 | "authors": [ 934 | { 935 | "name": "Kore Nordmann", 936 | "email": "mail@kore-nordmann.de" 937 | }, 938 | { 939 | "name": "Sebastian Bergmann", 940 | "email": "sebastian@phpunit.de" 941 | } 942 | ], 943 | "description": "Diff implementation", 944 | "homepage": "https://github.com/sebastianbergmann/diff", 945 | "keywords": [ 946 | "diff" 947 | ], 948 | "time": "2015-12-08 07:14:41" 949 | }, 950 | { 951 | "name": "sebastian/exporter", 952 | "version": "1.2.2", 953 | "source": { 954 | "type": "git", 955 | "url": "https://github.com/sebastianbergmann/exporter.git", 956 | "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" 957 | }, 958 | "dist": { 959 | "type": "zip", 960 | "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", 961 | "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", 962 | "shasum": "" 963 | }, 964 | "require": { 965 | "php": ">=5.3.3", 966 | "sebastian/recursion-context": "~1.0" 967 | }, 968 | "require-dev": { 969 | "ext-mbstring": "*", 970 | "phpunit/phpunit": "~4.4" 971 | }, 972 | "type": "library", 973 | "extra": { 974 | "branch-alias": { 975 | "dev-master": "1.3.x-dev" 976 | } 977 | }, 978 | "autoload": { 979 | "classmap": [ 980 | "src/" 981 | ] 982 | }, 983 | "notification-url": "https://packagist.org/downloads/", 984 | "license": [ 985 | "BSD-3-Clause" 986 | ], 987 | "authors": [ 988 | { 989 | "name": "Jeff Welch", 990 | "email": "whatthejeff@gmail.com" 991 | }, 992 | { 993 | "name": "Volker Dusch", 994 | "email": "github@wallbash.com" 995 | }, 996 | { 997 | "name": "Bernhard Schussek", 998 | "email": "bschussek@2bepublished.at" 999 | }, 1000 | { 1001 | "name": "Sebastian Bergmann", 1002 | "email": "sebastian@phpunit.de" 1003 | }, 1004 | { 1005 | "name": "Adam Harvey", 1006 | "email": "aharvey@php.net" 1007 | } 1008 | ], 1009 | "description": "Provides the functionality to export PHP variables for visualization", 1010 | "homepage": "http://www.github.com/sebastianbergmann/exporter", 1011 | "keywords": [ 1012 | "export", 1013 | "exporter" 1014 | ], 1015 | "time": "2016-06-17 09:04:28" 1016 | }, 1017 | { 1018 | "name": "sebastian/recursion-context", 1019 | "version": "1.0.2", 1020 | "source": { 1021 | "type": "git", 1022 | "url": "https://github.com/sebastianbergmann/recursion-context.git", 1023 | "reference": "913401df809e99e4f47b27cdd781f4a258d58791" 1024 | }, 1025 | "dist": { 1026 | "type": "zip", 1027 | "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", 1028 | "reference": "913401df809e99e4f47b27cdd781f4a258d58791", 1029 | "shasum": "" 1030 | }, 1031 | "require": { 1032 | "php": ">=5.3.3" 1033 | }, 1034 | "require-dev": { 1035 | "phpunit/phpunit": "~4.4" 1036 | }, 1037 | "type": "library", 1038 | "extra": { 1039 | "branch-alias": { 1040 | "dev-master": "1.0.x-dev" 1041 | } 1042 | }, 1043 | "autoload": { 1044 | "classmap": [ 1045 | "src/" 1046 | ] 1047 | }, 1048 | "notification-url": "https://packagist.org/downloads/", 1049 | "license": [ 1050 | "BSD-3-Clause" 1051 | ], 1052 | "authors": [ 1053 | { 1054 | "name": "Jeff Welch", 1055 | "email": "whatthejeff@gmail.com" 1056 | }, 1057 | { 1058 | "name": "Sebastian Bergmann", 1059 | "email": "sebastian@phpunit.de" 1060 | }, 1061 | { 1062 | "name": "Adam Harvey", 1063 | "email": "aharvey@php.net" 1064 | } 1065 | ], 1066 | "description": "Provides functionality to recursively process PHP variables", 1067 | "homepage": "http://www.github.com/sebastianbergmann/recursion-context", 1068 | "time": "2015-11-11 19:50:13" 1069 | }, 1070 | { 1071 | "name": "symfony/event-dispatcher", 1072 | "version": "v3.1.2", 1073 | "source": { 1074 | "type": "git", 1075 | "url": "https://github.com/symfony/event-dispatcher.git", 1076 | "reference": "7f9839ede2070f53e7e2f0849b9bd14748c434c5" 1077 | }, 1078 | "dist": { 1079 | "type": "zip", 1080 | "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/7f9839ede2070f53e7e2f0849b9bd14748c434c5", 1081 | "reference": "7f9839ede2070f53e7e2f0849b9bd14748c434c5", 1082 | "shasum": "" 1083 | }, 1084 | "require": { 1085 | "php": ">=5.5.9" 1086 | }, 1087 | "require-dev": { 1088 | "psr/log": "~1.0", 1089 | "symfony/config": "~2.8|~3.0", 1090 | "symfony/dependency-injection": "~2.8|~3.0", 1091 | "symfony/expression-language": "~2.8|~3.0", 1092 | "symfony/stopwatch": "~2.8|~3.0" 1093 | }, 1094 | "suggest": { 1095 | "symfony/dependency-injection": "", 1096 | "symfony/http-kernel": "" 1097 | }, 1098 | "type": "library", 1099 | "extra": { 1100 | "branch-alias": { 1101 | "dev-master": "3.1-dev" 1102 | } 1103 | }, 1104 | "autoload": { 1105 | "psr-4": { 1106 | "Symfony\\Component\\EventDispatcher\\": "" 1107 | }, 1108 | "exclude-from-classmap": [ 1109 | "/Tests/" 1110 | ] 1111 | }, 1112 | "notification-url": "https://packagist.org/downloads/", 1113 | "license": [ 1114 | "MIT" 1115 | ], 1116 | "authors": [ 1117 | { 1118 | "name": "Fabien Potencier", 1119 | "email": "fabien@symfony.com" 1120 | }, 1121 | { 1122 | "name": "Symfony Community", 1123 | "homepage": "https://symfony.com/contributors" 1124 | } 1125 | ], 1126 | "description": "Symfony EventDispatcher Component", 1127 | "homepage": "https://symfony.com", 1128 | "time": "2016-06-29 05:41:56" 1129 | }, 1130 | { 1131 | "name": "symfony/finder", 1132 | "version": "v3.1.2", 1133 | "source": { 1134 | "type": "git", 1135 | "url": "https://github.com/symfony/finder.git", 1136 | "reference": "8201978de88a9fa0923e18601bb17f1df9c721e7" 1137 | }, 1138 | "dist": { 1139 | "type": "zip", 1140 | "url": "https://api.github.com/repos/symfony/finder/zipball/8201978de88a9fa0923e18601bb17f1df9c721e7", 1141 | "reference": "8201978de88a9fa0923e18601bb17f1df9c721e7", 1142 | "shasum": "" 1143 | }, 1144 | "require": { 1145 | "php": ">=5.5.9" 1146 | }, 1147 | "type": "library", 1148 | "extra": { 1149 | "branch-alias": { 1150 | "dev-master": "3.1-dev" 1151 | } 1152 | }, 1153 | "autoload": { 1154 | "psr-4": { 1155 | "Symfony\\Component\\Finder\\": "" 1156 | }, 1157 | "exclude-from-classmap": [ 1158 | "/Tests/" 1159 | ] 1160 | }, 1161 | "notification-url": "https://packagist.org/downloads/", 1162 | "license": [ 1163 | "MIT" 1164 | ], 1165 | "authors": [ 1166 | { 1167 | "name": "Fabien Potencier", 1168 | "email": "fabien@symfony.com" 1169 | }, 1170 | { 1171 | "name": "Symfony Community", 1172 | "homepage": "https://symfony.com/contributors" 1173 | } 1174 | ], 1175 | "description": "Symfony Finder Component", 1176 | "homepage": "https://symfony.com", 1177 | "time": "2016-06-29 05:41:56" 1178 | }, 1179 | { 1180 | "name": "symfony/process", 1181 | "version": "v3.1.2", 1182 | "source": { 1183 | "type": "git", 1184 | "url": "https://github.com/symfony/process.git", 1185 | "reference": "5c11a1a4d4016662eeaf0f8757958c7de069f9a0" 1186 | }, 1187 | "dist": { 1188 | "type": "zip", 1189 | "url": "https://api.github.com/repos/symfony/process/zipball/5c11a1a4d4016662eeaf0f8757958c7de069f9a0", 1190 | "reference": "5c11a1a4d4016662eeaf0f8757958c7de069f9a0", 1191 | "shasum": "" 1192 | }, 1193 | "require": { 1194 | "php": ">=5.5.9" 1195 | }, 1196 | "type": "library", 1197 | "extra": { 1198 | "branch-alias": { 1199 | "dev-master": "3.1-dev" 1200 | } 1201 | }, 1202 | "autoload": { 1203 | "psr-4": { 1204 | "Symfony\\Component\\Process\\": "" 1205 | }, 1206 | "exclude-from-classmap": [ 1207 | "/Tests/" 1208 | ] 1209 | }, 1210 | "notification-url": "https://packagist.org/downloads/", 1211 | "license": [ 1212 | "MIT" 1213 | ], 1214 | "authors": [ 1215 | { 1216 | "name": "Fabien Potencier", 1217 | "email": "fabien@symfony.com" 1218 | }, 1219 | { 1220 | "name": "Symfony Community", 1221 | "homepage": "https://symfony.com/contributors" 1222 | } 1223 | ], 1224 | "description": "Symfony Process Component", 1225 | "homepage": "https://symfony.com", 1226 | "time": "2016-06-29 05:42:25" 1227 | }, 1228 | { 1229 | "name": "symfony/yaml", 1230 | "version": "v3.1.2", 1231 | "source": { 1232 | "type": "git", 1233 | "url": "https://github.com/symfony/yaml.git", 1234 | "reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de" 1235 | }, 1236 | "dist": { 1237 | "type": "zip", 1238 | "url": "https://api.github.com/repos/symfony/yaml/zipball/2884c26ce4c1d61aebf423a8b912950fe7c764de", 1239 | "reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de", 1240 | "shasum": "" 1241 | }, 1242 | "require": { 1243 | "php": ">=5.5.9" 1244 | }, 1245 | "type": "library", 1246 | "extra": { 1247 | "branch-alias": { 1248 | "dev-master": "3.1-dev" 1249 | } 1250 | }, 1251 | "autoload": { 1252 | "psr-4": { 1253 | "Symfony\\Component\\Yaml\\": "" 1254 | }, 1255 | "exclude-from-classmap": [ 1256 | "/Tests/" 1257 | ] 1258 | }, 1259 | "notification-url": "https://packagist.org/downloads/", 1260 | "license": [ 1261 | "MIT" 1262 | ], 1263 | "authors": [ 1264 | { 1265 | "name": "Fabien Potencier", 1266 | "email": "fabien@symfony.com" 1267 | }, 1268 | { 1269 | "name": "Symfony Community", 1270 | "homepage": "https://symfony.com/contributors" 1271 | } 1272 | ], 1273 | "description": "Symfony Yaml Component", 1274 | "homepage": "https://symfony.com", 1275 | "time": "2016-06-29 05:41:56" 1276 | }, 1277 | { 1278 | "name": "webmozart/assert", 1279 | "version": "1.0.2", 1280 | "source": { 1281 | "type": "git", 1282 | "url": "https://github.com/webmozart/assert.git", 1283 | "reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde" 1284 | }, 1285 | "dist": { 1286 | "type": "zip", 1287 | "url": "https://api.github.com/repos/webmozart/assert/zipball/30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde", 1288 | "reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde", 1289 | "shasum": "" 1290 | }, 1291 | "require": { 1292 | "php": ">=5.3.3" 1293 | }, 1294 | "require-dev": { 1295 | "phpunit/phpunit": "^4.6" 1296 | }, 1297 | "type": "library", 1298 | "extra": { 1299 | "branch-alias": { 1300 | "dev-master": "1.0-dev" 1301 | } 1302 | }, 1303 | "autoload": { 1304 | "psr-4": { 1305 | "Webmozart\\Assert\\": "src/" 1306 | } 1307 | }, 1308 | "notification-url": "https://packagist.org/downloads/", 1309 | "license": [ 1310 | "MIT" 1311 | ], 1312 | "authors": [ 1313 | { 1314 | "name": "Bernhard Schussek", 1315 | "email": "bschussek@gmail.com" 1316 | } 1317 | ], 1318 | "description": "Assertions to validate method input/output with nice error messages.", 1319 | "keywords": [ 1320 | "assert", 1321 | "check", 1322 | "validate" 1323 | ], 1324 | "time": "2015-08-24 13:29:44" 1325 | } 1326 | ], 1327 | "aliases": [], 1328 | "minimum-stability": "stable", 1329 | "stability-flags": [], 1330 | "prefer-stable": false, 1331 | "prefer-lowest": false, 1332 | "platform": [], 1333 | "platform-dev": [] 1334 | } 1335 | -------------------------------------------------------------------------------- /04-import-from-sitemap/fixtures/sample-page.html: -------------------------------------------------------------------------------- 1 | <!DOCTYPE html> 2 | <html> 3 | <head> 4 | <title>This is the title 5 | 6 | 7 | 8 |
9 |
10 |
11 |
This is the article contents
12 |
13 |
14 |
15 | 16 | -------------------------------------------------------------------------------- /04-import-from-sitemap/fixtures/sample-sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | http://gathercontent.com/page-sitemap.xml 5 | 2016-06-12T13:24:07+01:00 6 | 7 | 8 | http://gathercontent.com/case-studies-sitemap.xml 9 | 2016-07-07T11:56:40+01:00 10 | 11 | 12 | http://gathercontent.com/articles-sitemap.xml 13 | 2016-03-01T17:04:10+00:00 14 | 15 | 16 | http://gathercontent.com/resources-sitemap.xml 17 | 2016-07-05T09:11:45+01:00 18 | 19 | 20 | http://gathercontent.com/thanks-sitemap.xml 21 | 2016-06-28T16:12:37+01:00 22 | 23 | 24 | http://gathercontent.com/integrations-sitemap.xml 25 | 2016-07-07T14:52:26+01:00 26 | 27 | 28 | http://gathercontent.com/careers-sitemap.xml 29 | 2016-05-16T14:30:06+01:00 30 | 31 | 32 | http://gathercontent.com/resource_category-sitemap.xml 33 | 2016-07-05T09:11:45+01:00 34 | 35 | 36 | -------------------------------------------------------------------------------- /04-import-from-sitemap/spec/ContentScraperSpec.php: -------------------------------------------------------------------------------- 1 | scrapeContent(file_get_contents(__DIR__ . '/../fixtures/sample-page.html'), 'title') 13 | ->shouldReturn('This is the title'); 14 | 15 | $this->scrapeContent(file_get_contents(__DIR__ . '/../fixtures/sample-page.html'), 'article') 16 | ->shouldReturn('This is the article contents'); 17 | } 18 | 19 | function it_returns_an_empty_string_if_the_xpath_selector_cannot_be_found_in_the_content() 20 | { 21 | $this->scrapeContent('

hello

', 'foo')->shouldReturn(''); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /04-import-from-sitemap/spec/ContentToFieldMapperSpec.php: -------------------------------------------------------------------------------- 1 | mapContentToFields( 13 | file_get_contents(__DIR__ . '/../fixtures/sample-page.html'), 14 | ['name' => 'title', 'imported' => 'article'] 15 | ); 16 | 17 | $mapped['name']->shouldBe('This is the title'); 18 | $mapped['imported']->shouldContain('This is the article content'); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /04-import-from-sitemap/spec/FieldNormaliserSpec.php: -------------------------------------------------------------------------------- 1 | 'This is the page title', 14 | 'imported' => 'This is the content' 15 | ]; 16 | 17 | $this->normalise($hashMap, 123)->shouldReturn([ 18 | 'project_id' => 123, 19 | 'name' => 'This is the page title', 20 | 'config' => base64_encode(json_encode(json_decode(' 21 | [{ 22 | "label": "Content", 23 | "name": "tab1", 24 | "hidden": false, 25 | "elements": [{ 26 | "type": "text", 27 | "name": "el1", 28 | "required": false, 29 | "label": "imported", 30 | "value": "This is the content", 31 | "microcopy": "", 32 | "limit_type": "words", 33 | "limit": 0, 34 | "plain_text": false 35 | }] 36 | }]' 37 | ))) 38 | ]); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /04-import-from-sitemap/spec/ImportCommandSpec.php: -------------------------------------------------------------------------------- 1 | shouldImplement(Command::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /04-import-from-sitemap/spec/SitemapScraperSpec.php: -------------------------------------------------------------------------------- 1 | listUrls(__DIR__ . '/../fixtures/sample-sitemap.xml')->shouldReturn([ 13 | 'http://gathercontent.com/page-sitemap.xml', 14 | 'http://gathercontent.com/case-studies-sitemap.xml', 15 | 'http://gathercontent.com/articles-sitemap.xml', 16 | 'http://gathercontent.com/resources-sitemap.xml', 17 | 'http://gathercontent.com/thanks-sitemap.xml', 18 | 'http://gathercontent.com/integrations-sitemap.xml', 19 | 'http://gathercontent.com/careers-sitemap.xml', 20 | 'http://gathercontent.com/resource_category-sitemap.xml' 21 | ]); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /04-import-from-sitemap/src/ContentScraper.php: -------------------------------------------------------------------------------- 1 | filter($xpathSelector); 12 | 13 | if ($filtered->count() > 0) { 14 | return $filtered->text(); 15 | } 16 | 17 | return ''; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /04-import-from-sitemap/src/ContentToFieldMapper.php: -------------------------------------------------------------------------------- 1 | scrapeContent($content, $xpathSelector); 11 | }, $map); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /04-import-from-sitemap/src/FieldNormaliser.php: -------------------------------------------------------------------------------- 1 | type = "text"; 28 | $field->name = "el1"; 29 | $field->required = false; 30 | $field->label = "imported"; 31 | $field->value = $hashMap['imported']; 32 | $field->microcopy = ""; 33 | $field->limit_type = "words"; 34 | $field->limit = 0; 35 | $field->plain_text = false; 36 | 37 | $elements = [$field]; 38 | 39 | $tab = new stdClass(); 40 | $tab->label = "Content"; 41 | $tab->name = "tab1"; 42 | $tab->hidden = false; 43 | $tab->elements = $elements; 44 | 45 | $config = [$tab]; 46 | return [ 47 | 'project_id' => $projectId, 48 | 'name' => $hashMap['name'], 49 | // 'parent_id' (optional) Parent Item ID 50 | // 'template_id' (optional) Template ID to apply 51 | 'config' => base64_encode(json_encode($config)) 52 | ]; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /04-import-from-sitemap/src/ImportCommand.php: -------------------------------------------------------------------------------- 1 | setName('scrape')->setDescription('Scrape content and import from an existing website'); 19 | } 20 | 21 | public function execute(InputInterface $input, OutputInterface $output) 22 | { 23 | $this->httpClient = new Client([ 24 | 'base_uri' => 'https://api.gathercontent.com/', 25 | 'headers' => [ 26 | 'Accept' => 'application/vnd.gathercontent.v0.5+json' 27 | ] 28 | ]); 29 | 30 | $io = new SymfonyStyle($input, $output); 31 | 32 | $username = $io->ask('What is your username?'); 33 | $apiKey = $io->ask('What is your API key?'); 34 | 35 | $io->text('Validating username and API key...'); 36 | 37 | if (!$this->authenticate($username, $apiKey)) { 38 | $io->error('Hm, your username and API key are not working right now.'); 39 | exit; 40 | } 41 | 42 | $io->success('Looks good.'); 43 | 44 | // which account would you like to use? 45 | $accounts = $this->lookupAccounts($username, $apiKey); 46 | 47 | if (count($accounts) == 1) { 48 | $accountId = reset(array_keys($accounts)); 49 | } else { 50 | $accountName = $io->choice('Which account would you like to use?', array_values($accounts)); 51 | $accountId = array_search($accountName, $accounts); 52 | } 53 | 54 | // what project would you like to import to 55 | $projects = $this->lookupProjects($username, $apiKey, $accountId); 56 | 57 | $projectName = $io->choice( 58 | 'What project would you like to import to? (default is a new project)', 59 | array_merge(['Create a new project'], $projects), 60 | 'Create a new project' 61 | ); 62 | $projectId = array_search($projectName, $projects); 63 | 64 | if ($projectId === false) { 65 | // create a new project 66 | $projectName = $io->ask('What would you like to call the project?'); 67 | // select a type 68 | $projectType = $io->choice( 69 | 'Select a type for the project', 70 | [ 71 | 'website-build', 72 | 'ongoing-website-content', 73 | 'marketing-editorial-content', 74 | 'email-marketing-content', 75 | 'other' 76 | ] 77 | ); 78 | 79 | if (!$this->createProject($username, $apiKey, $accountId, $projectName, $projectType)) { 80 | $io->error('Unable to create project!'); 81 | exit; 82 | } 83 | $newProjects = $this->lookupProjects($username, $apiKey, $accountId); 84 | $newProject = array_diff($newProjects, $projects); 85 | $projectId = key($newProject); 86 | $projectName = current($newProject); 87 | } 88 | 89 | $io->text('Importing to project: ' . $projectName); 90 | 91 | $sitemap = $io->ask('Please provide a link to your sitemap.xml (remember the leading http://)'); 92 | 93 | $io->text('Searching for items in ' . $sitemap); 94 | 95 | $urls = (new SitemapScraper())->listUrls($sitemap); 96 | $urlCount = count($urls); 97 | if (!$urlCount) { 98 | $io->error('No pages found at ' . $sitemap); 99 | exit; 100 | } 101 | 102 | $io->text('We found ' . $urlCount . ' pages to import.'); 103 | 104 | $cssSelector = $io->ask('What CSS selector would you like to import from? (e.g. body, .content, #main)', 'article'); 105 | 106 | if (!$io->confirm('Ok to import? (this may take a while)')) { 107 | exit; 108 | } 109 | 110 | $io->progressStart($urlCount); 111 | 112 | $contentToFieldMapper = new ContentToFieldMapper(); 113 | $normaliser = new FieldNormaliser(); 114 | 115 | foreach ($urls as $url) { 116 | $hashMap = $contentToFieldMapper->mapContentToFields( 117 | file_get_contents($url), 118 | ['name' => 'title', 'imported' => $cssSelector] 119 | ); 120 | $fields = $normaliser->normalise($hashMap, $projectId); 121 | $this->createItem($fields, $username, $apiKey); 122 | $io->progressAdvance(); 123 | } 124 | 125 | $io->progressFinish(); 126 | 127 | $io->success("We're all done!"); 128 | } 129 | 130 | private function authenticate($username, $apiKey) 131 | { 132 | return $this->httpClient->get('me', ['auth' => [$username, $apiKey]])->getStatusCode() === 200; 133 | } 134 | 135 | private function lookupAccounts($username, $apiKey) 136 | { 137 | $jsonResponse = $this->httpClient->get('accounts', ['auth' => [$username, $apiKey]])->getBody(); 138 | $response = json_decode($jsonResponse); 139 | 140 | return array_reduce($response->data, function ($accounts, $account) { 141 | $accounts[$account->id] = $account->name; 142 | 143 | return $accounts; 144 | }, []); 145 | } 146 | 147 | private function lookupProjects($username, $apiKey, $accountId) 148 | { 149 | $options = ['auth' => [$username, $apiKey], 'query' => ['account_id' => $accountId]]; 150 | $jsonResponse = $this->httpClient->get('projects', $options)->getBody(); 151 | $response = json_decode($jsonResponse); 152 | 153 | return array_reduce($response->data, function ($projects, $project) { 154 | $projects[$project->id] = $project->name; 155 | 156 | return $projects; 157 | }, []); 158 | } 159 | 160 | private function createProject($username, $apiKey, $accountId, $projectName, $projectType) 161 | { 162 | $options = [ 163 | 'auth' => [$username, $apiKey], 164 | 'form_params' => [ 165 | 'account_id' => $accountId, 166 | 'name' => $projectName, 167 | 'type' => $projectType 168 | ] 169 | ]; 170 | 171 | return $this->httpClient->post('projects', $options)->getStatusCode() === 202; 172 | } 173 | 174 | private function createItem($data, $username, $apiKey) 175 | { 176 | $options = [ 177 | 'auth' => [$username, $apiKey], 178 | 'form_params' => $data 179 | ]; 180 | 181 | return $this->httpClient->post('items', $options)->getStatusCode() === 202; 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /04-import-from-sitemap/src/ScrapeApplication.php: -------------------------------------------------------------------------------- 1 | setArguments(); 45 | 46 | return $inputDefinition; 47 | }} 48 | -------------------------------------------------------------------------------- /04-import-from-sitemap/src/SitemapScraper.php: -------------------------------------------------------------------------------- 1 | loc)); 12 | } 13 | return $urls; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /05-gravity-forms-add-on/.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | -------------------------------------------------------------------------------- /05-gravity-forms-add-on/README.md: -------------------------------------------------------------------------------- 1 | # Send users from Gravity Forms to GatherContent 2 | 3 | ## Installation 4 | 5 | Clone this package from GitHub 6 | 7 | ```bash 8 | $ git clone https://github.com/gathercontent/api-examples.git 9 | ``` 10 | 11 | Move contents from `05-gravity-forms-add-on` to your `wp-content/plugins/gravity_gc` folder 12 | 13 | ```bash 14 | $ cd wp-content/plugins/gravity_gc 15 | ``` 16 | 17 | Install the package dependencies 18 | 19 | ```bash 20 | $ composer install 21 | ``` 22 | 23 | Activate from wp-admin 24 | -------------------------------------------------------------------------------- /05-gravity-forms-add-on/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "guzzlehttp/guzzle": "~5.3" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /05-gravity-forms-add-on/composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "be386ae184891df17c51f7cacdc72478", 8 | "content-hash": "5c59c0132551de80d8ed68a96ebc2296", 9 | "packages": [ 10 | { 11 | "name": "guzzlehttp/guzzle", 12 | "version": "5.3.0", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/guzzle/guzzle.git", 16 | "reference": "f3c8c22471cb55475105c14769644a49c3262b93" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f3c8c22471cb55475105c14769644a49c3262b93", 21 | "reference": "f3c8c22471cb55475105c14769644a49c3262b93", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "guzzlehttp/ringphp": "^1.1", 26 | "php": ">=5.4.0" 27 | }, 28 | "require-dev": { 29 | "ext-curl": "*", 30 | "phpunit/phpunit": "^4.0", 31 | "psr/log": "^1.0" 32 | }, 33 | "type": "library", 34 | "extra": { 35 | "branch-alias": { 36 | "dev-master": "5.0-dev" 37 | } 38 | }, 39 | "autoload": { 40 | "psr-4": { 41 | "GuzzleHttp\\": "src/" 42 | } 43 | }, 44 | "notification-url": "https://packagist.org/downloads/", 45 | "license": [ 46 | "MIT" 47 | ], 48 | "authors": [ 49 | { 50 | "name": "Michael Dowling", 51 | "email": "mtdowling@gmail.com", 52 | "homepage": "https://github.com/mtdowling" 53 | } 54 | ], 55 | "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", 56 | "homepage": "http://guzzlephp.org/", 57 | "keywords": [ 58 | "client", 59 | "curl", 60 | "framework", 61 | "http", 62 | "http client", 63 | "rest", 64 | "web service" 65 | ], 66 | "time": "2015-05-20 03:47:55" 67 | }, 68 | { 69 | "name": "guzzlehttp/ringphp", 70 | "version": "1.1.0", 71 | "source": { 72 | "type": "git", 73 | "url": "https://github.com/guzzle/RingPHP.git", 74 | "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b" 75 | }, 76 | "dist": { 77 | "type": "zip", 78 | "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b", 79 | "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b", 80 | "shasum": "" 81 | }, 82 | "require": { 83 | "guzzlehttp/streams": "~3.0", 84 | "php": ">=5.4.0", 85 | "react/promise": "~2.0" 86 | }, 87 | "require-dev": { 88 | "ext-curl": "*", 89 | "phpunit/phpunit": "~4.0" 90 | }, 91 | "suggest": { 92 | "ext-curl": "Guzzle will use specific adapters if cURL is present" 93 | }, 94 | "type": "library", 95 | "extra": { 96 | "branch-alias": { 97 | "dev-master": "1.1-dev" 98 | } 99 | }, 100 | "autoload": { 101 | "psr-4": { 102 | "GuzzleHttp\\Ring\\": "src/" 103 | } 104 | }, 105 | "notification-url": "https://packagist.org/downloads/", 106 | "license": [ 107 | "MIT" 108 | ], 109 | "authors": [ 110 | { 111 | "name": "Michael Dowling", 112 | "email": "mtdowling@gmail.com", 113 | "homepage": "https://github.com/mtdowling" 114 | } 115 | ], 116 | "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.", 117 | "time": "2015-05-20 03:37:09" 118 | }, 119 | { 120 | "name": "guzzlehttp/streams", 121 | "version": "3.0.0", 122 | "source": { 123 | "type": "git", 124 | "url": "https://github.com/guzzle/streams.git", 125 | "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5" 126 | }, 127 | "dist": { 128 | "type": "zip", 129 | "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", 130 | "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", 131 | "shasum": "" 132 | }, 133 | "require": { 134 | "php": ">=5.4.0" 135 | }, 136 | "require-dev": { 137 | "phpunit/phpunit": "~4.0" 138 | }, 139 | "type": "library", 140 | "extra": { 141 | "branch-alias": { 142 | "dev-master": "3.0-dev" 143 | } 144 | }, 145 | "autoload": { 146 | "psr-4": { 147 | "GuzzleHttp\\Stream\\": "src/" 148 | } 149 | }, 150 | "notification-url": "https://packagist.org/downloads/", 151 | "license": [ 152 | "MIT" 153 | ], 154 | "authors": [ 155 | { 156 | "name": "Michael Dowling", 157 | "email": "mtdowling@gmail.com", 158 | "homepage": "https://github.com/mtdowling" 159 | } 160 | ], 161 | "description": "Provides a simple abstraction over streams of data", 162 | "homepage": "http://guzzlephp.org/", 163 | "keywords": [ 164 | "Guzzle", 165 | "stream" 166 | ], 167 | "time": "2014-10-12 19:18:40" 168 | }, 169 | { 170 | "name": "react/promise", 171 | "version": "v2.4.1", 172 | "source": { 173 | "type": "git", 174 | "url": "https://github.com/reactphp/promise.git", 175 | "reference": "8025426794f1944de806618671d4fa476dc7626f" 176 | }, 177 | "dist": { 178 | "type": "zip", 179 | "url": "https://api.github.com/repos/reactphp/promise/zipball/8025426794f1944de806618671d4fa476dc7626f", 180 | "reference": "8025426794f1944de806618671d4fa476dc7626f", 181 | "shasum": "" 182 | }, 183 | "require": { 184 | "php": ">=5.4.0" 185 | }, 186 | "type": "library", 187 | "extra": { 188 | "branch-alias": { 189 | "dev-master": "2.0-dev" 190 | } 191 | }, 192 | "autoload": { 193 | "psr-4": { 194 | "React\\Promise\\": "src/" 195 | }, 196 | "files": [ 197 | "src/functions_include.php" 198 | ] 199 | }, 200 | "notification-url": "https://packagist.org/downloads/", 201 | "license": [ 202 | "MIT" 203 | ], 204 | "authors": [ 205 | { 206 | "name": "Jan Sorgalla", 207 | "email": "jsorgalla@gmail.com" 208 | } 209 | ], 210 | "description": "A lightweight implementation of CommonJS Promises/A for PHP", 211 | "time": "2016-05-03 17:50:52" 212 | } 213 | ], 214 | "packages-dev": [], 215 | "aliases": [], 216 | "minimum-stability": "stable", 217 | "stability-flags": [], 218 | "prefer-stable": false, 219 | "prefer-lowest": false, 220 | "platform": [], 221 | "platform-dev": [] 222 | } 223 | -------------------------------------------------------------------------------- /05-gravity-forms-add-on/css/admin.css: -------------------------------------------------------------------------------- 1 | .gc_row { 2 | margin-bottom: 10px; 3 | } 4 | 5 | .gform_tab_container label { 6 | font-weight: bold; 7 | } 8 | 9 | .gc_row .input { 10 | width: 50%; 11 | } 12 | 13 | .gfield_error { 14 | color: #790000; 15 | width: 50%; 16 | } 17 | 18 | .gc_row h2 { 19 | margin-top: 30px; 20 | } 21 | -------------------------------------------------------------------------------- /05-gravity-forms-add-on/gravity_gc.php: -------------------------------------------------------------------------------- 1 | 'gf_gathercontent', 'label' => 'GatherContent', 'callback' => array(&$this, 'options'), "permission" => $has_full_access ? "gform_full_access" : "gravityforms_edit_forms" ); 26 | return $menu_items; 27 | } 28 | 29 | 30 | /* Send data to GC */ 31 | 32 | public function check_form($lead) { 33 | $api = get_option('gravity_gc_api'); 34 | 35 | if($api){ 36 | $this->auth = $api['auth']; 37 | 38 | $mappings = get_option('gravity_gc_' . $lead['form_id']); 39 | if($mappings) { 40 | try { 41 | 42 | if($mappings['template_id'] > 0) { 43 | $config = $this->api('get', "/templates/{$mappings['template_id']}")['data']['config']; 44 | 45 | $fields = array_flip($mappings['fields']); 46 | 47 | foreach($config as &$tab) { 48 | foreach($tab['elements'] as &$element) { 49 | if(isset($fields[$element['name']])) { 50 | $element['value'] = $lead[$fields[$element['name']]]; 51 | } 52 | } 53 | } 54 | 55 | $fields = $mappings['title']['fields']; 56 | $lengths = $mappings['title']['lengths']; 57 | 58 | $title = ''; 59 | foreach($fields as $field) { 60 | $field = (string) $field; 61 | $title .= ' '; 62 | if($lengths[$field] != 0) { 63 | $title .= substr($lead[$field], 0, $lengths[$field]); 64 | } 65 | else { 66 | $title .= $lead[$field]; 67 | } 68 | } 69 | 70 | $this->api('post', '/items', array( 71 | 'project_id' => $mappings['project_id'], 72 | 'template_id' => $mappings['template_id'], 73 | 'name' => $title, 74 | 'config' => base64_encode(json_encode($config)) 75 | )); 76 | } 77 | } catch(Exception $e) { 78 | $form = GFAPI::get_form($lead['form_id']); 79 | 80 | $notification_id = key($form['notifications']); 81 | 82 | $notification = $form['notifications'][$notification_id]; 83 | 84 | $notification['subject'] = 'Failed to send lead data to GatherContent.'; 85 | $notification['message'] = 'Failed to send lead data to GatherContent. ' . $e->getMessage() .'

{all_fields}'; 86 | 87 | GFCommon::send_notification($notification, $form, $lead); 88 | } 89 | } 90 | } 91 | } 92 | 93 | 94 | /* Save Form Options */ 95 | 96 | public function save_settings() { 97 | if(isset($_POST['gf_gathercontent_nonce'])) { 98 | 99 | $current_tab = rgempty('view', $_GET) ? 'api' : rgget('view'); 100 | 101 | if(!in_array($current_tab, array('api', 'mapping'))) { 102 | $current_tab = 'api'; 103 | } 104 | 105 | 106 | check_admin_referer("gf_gathercontent", "gf_gathercontent_nonce"); 107 | 108 | $gravity_gc = $_POST['gravity_gc']; 109 | 110 | if($current_tab == 'api') { 111 | 112 | $api = array( 113 | 'auth' => array( 114 | $gravity_gc['email'], 115 | $gravity_gc['apikey'], 116 | ), 117 | 'account' => 0, 118 | ); 119 | 120 | if(isset($gravity_gc['account'])) { 121 | $api['account'] = $gravity_gc['account']; 122 | } 123 | 124 | update_option('gravity_gc_api', $api); 125 | } 126 | 127 | if($current_tab == 'mapping') { 128 | 129 | $form_id = rgempty('form_id', $_GET) ? -1 : rgget('form_id'); 130 | $form_id = intval($form_id); 131 | 132 | $project_id = rgempty('project_id', $_GET) ? -1 : rgget('project_id'); 133 | $project_id = intval($project_id); 134 | 135 | $template_id = rgempty('template_id', $_GET) ? -1 : rgget('template_id'); 136 | $template_id = intval($template_id); 137 | 138 | if($form_id > -1) { 139 | 140 | $mapping = array( 141 | 'project_id' => $project_id, 142 | 'template_id' => $template_id, 143 | 'title' => array( 144 | 'fields' => array(), 145 | 'lengths' => array() 146 | ), 147 | 'fields' => array() 148 | ); 149 | 150 | $title = $gravity_gc['title']; 151 | 152 | if(isset($title['fields'])) { 153 | $mapping['title']['fields'] = $title['fields']; 154 | 155 | foreach($title['fields'] as $field) { 156 | $mapping['title']['lengths'][$field] = $title['lengths'][$field]; 157 | } 158 | } 159 | 160 | 161 | $fields = $gravity_gc['fields']; 162 | 163 | if(!empty($fields)) { 164 | foreach($fields as $field_id => $gc_name) { 165 | if(intval($gc_name) !== -1) { 166 | $mapping['fields'][$field_id] = $gc_name; 167 | } 168 | } 169 | } 170 | 171 | update_option('gravity_gc_' . $form_id, $mapping); 172 | } 173 | } 174 | } 175 | 176 | } 177 | 178 | 179 | /* Options Pages */ 180 | 181 | public function _options_api() { 182 | 183 | if(!empty($this->auth[0])) { 184 | $html = $this->_get_accounts_dropdown(); 185 | } 186 | else { 187 | $html = ''; 188 | } 189 | ?> 190 |
191 | 192 |
193 | 194 |
195 | 196 |
197 |
198 |
199 | 200 |
201 | 202 |
203 |
204 |
205 | 206 |
207 | 208 |
209 | 'mapping', 227 | ); 228 | 229 | $select = ' 230 | '; 250 | 251 | 252 | 253 | $mappings = get_option('gravity_gc_' . $form_id); 254 | if(!$mappings) { 255 | $mappings = array( 256 | 'project_id' => $project_id, 257 | 'template_id' => $template_id, 258 | 'title' => array(), 259 | 'fields' => array() 260 | ); 261 | } 262 | 263 | ?> 264 |
265 | 266 |
267 | 268 | 269 |
270 | 0) { 272 | ?> 273 |
274 | 275 | _get_projects_dropdown($project_id) ?> 276 |
277 | 0) { 279 | ?> 280 |
281 | 282 | _get_templates_dropdown($project_id, $template_id) ?> 283 |
284 | 0) { 286 | $form = GFAPI::get_form($form_id); 287 | 288 | $config = $this->_get_config_array($template_id); 289 | 290 | $fields = array_flip(rgempty('fields', $mappings['title']) ? array() : $mappings['title']['fields']); 291 | $lengths = rgempty('lengths', $mappings['title']) ? array() : $mappings['title']['lengths']; 292 | ?> 293 |
294 |

Title:

295 |
296 | 317 |
'; 318 | echo ' 319 | '; 320 | } 321 | } 322 | else { 323 | $id = (string) $field['id']; 324 | $length = isset($lengths[$id]) ? $lengths[$id] : 0; 325 | $length_html .= ' 326 | '; 330 | 331 | echo ' 332 | '; 333 | } 334 | 335 | } 336 | ?> 337 | 338 |
339 |
340 |

Title Field Lengths:

341 | 342 |
343 | 344 |
345 |

Fields:

346 |
347 | 359 |
360 | 361 |
362 | _config_dropdown($input['id'], $config, $mappings['fields']) ?> 363 |
364 |
365 | 370 |
371 | 372 |
373 | _config_dropdown($field['id'], $config, $mappings['fields']) ?> 374 |
375 |
376 | 380 | 381 | 386 |
387 | get_tabs(); 406 | 407 | // kind of boring having to pass the title, optionally get it from the settings tab 408 | if(!$title) { 409 | foreach($setting_tabs as $tab) { 410 | if($tab['name'] == $current_tab) 411 | $title = $tab['label']; 412 | } 413 | } 414 | ?> 415 |
416 |

417 | 418 |
419 | 436 | 437 |
438 |
439 | {$function}(); 442 | ?> 443 |
444 |
445 |
446 |
447 | (Do not send)'; 458 | $optgroup_open = false; 459 | foreach($config as $field) { 460 | if(!isset($field['name'])) { 461 | if($optgroup_open) { 462 | $html .= ''; 463 | } 464 | $html .= ''; 465 | } 466 | else { 467 | $html .= ''; 468 | } 469 | } 470 | if($optgroup_open) { 471 | $html .= ''; 472 | } 473 | 474 | return ' 475 | '; 476 | } 477 | 478 | private function _get_config_array($template_id) { 479 | $options = array(); 480 | 481 | $template = $this->templates[$template_id]; 482 | 483 | foreach($template as $tab) { 484 | $options[] = array('label' => $tab['label']); 485 | 486 | foreach($tab['elements'] as $element) { 487 | $options[] = array('label' => $element['label'], 'name' => $element['name']); 488 | } 489 | } 490 | 491 | return $options; 492 | } 493 | 494 | private function _get_accounts_dropdown() { 495 | try { 496 | $accounts = $this->api('get', '/accounts')['data']; 497 | 498 | $html = ' 499 | 500 |
501 | 508 |
'; 509 | 510 | return $html; 511 | 512 | } catch(Exception $e) { 513 | } 514 | 515 | return ''; 516 | } 517 | 518 | private function _get_projects_dropdown($project_id) { 519 | try { 520 | $projects = $this->api('get', '/projects', array( 521 | 'account_id' => $this->account 522 | ))['data']; 523 | 524 | $html = ' 525 | '; 538 | 539 | return $html; 540 | 541 | } catch(Exception $e) { 542 | } 543 | 544 | return ''; 545 | } 546 | 547 | private function _get_templates_dropdown($project_id, $template_id) { 548 | try { 549 | $templates = $this->api('get', '/templates', array( 550 | 'project_id' => $project_id 551 | ))['data']; 552 | 553 | $html = ' 554 | '; 567 | 568 | return $html; 569 | 570 | } catch(Exception $e) { 571 | } 572 | 573 | return ''; 574 | } 575 | 576 | public function get_tabs() { 577 | 578 | $setting_tabs = array(); 579 | $setting_tabs[] = array('name' => 'api', 'label' => 'API'); 580 | 581 | $api = get_option('gravity_gc_api'); 582 | 583 | if($api){ 584 | $this->auth = $api['auth']; 585 | $this->account = $api['account']; 586 | 587 | $setting_tabs[] = array('name' => 'mapping' , 'label' => 'Mappings'); 588 | } 589 | 590 | return $setting_tabs; 591 | } 592 | 593 | private function api($method, $url, $params=array()) { 594 | 595 | $client = new Client( 596 | array( 597 | 'base_url' => 'https://api.gathercontent.com', 598 | 'defaults' => array( 599 | 'auth' => $this->auth, 600 | 'headers' => array( 601 | 'Accept' => 'application/vnd.gathercontent.v0.5+json', 602 | ), 603 | ), 604 | ) 605 | ); 606 | 607 | if(!empty($params)) { 608 | $key = 'body'; 609 | if($method == 'get') { 610 | $key = 'query'; 611 | } 612 | 613 | $params = array( 614 | $key => $params 615 | ); 616 | } 617 | 618 | return json_decode($client->{$method}($url, $params)->getBody(), true); 619 | } 620 | 621 | 622 | public function ajax_get_accounts() { 623 | $out = array('error' => 'Verification failed, please refreshing the item and try again .'); 624 | if ( isset($_POST['_wpnonce']) ) { 625 | if ( wp_verify_nonce( $_POST['_wpnonce'], 'gf_gathercontent' ) ) { 626 | $this->auth = array( 627 | $_POST['email'], 628 | $_POST['apikey'] 629 | ); 630 | 631 | $success = true; 632 | $html = $this->_get_accounts_dropdown(); 633 | 634 | if(empty($html)) { 635 | $success = false; 636 | $html = '
Invalid credentials
'; 637 | } 638 | 639 | echo json_encode(array( 640 | 'success' => $success, 641 | 'html' => $html 642 | )); 643 | exit; 644 | } 645 | } 646 | echo json_encode( $out ); 647 | exit; 648 | } 649 | 650 | } 651 | 652 | new GravityGC; 653 | -------------------------------------------------------------------------------- /05-gravity-forms-add-on/js/admin.js: -------------------------------------------------------------------------------- 1 | ;(function($){ 2 | $(document).ready(function() { 3 | $('.ajax-get-gc-accounts').on('click', function(e) { 4 | var $t = $(this); 5 | e.preventDefault(); 6 | var data = { 7 | '_wpnonce': $('#gf_gathercontent_nonce').val(), 8 | 'action': 'gravity_gc_get_accounts', 9 | 'email': $('#gravity_gc_email').val(), 10 | 'apikey': $('#gravity_gc_apikey').val() 11 | }; 12 | 13 | $.ajax({ 14 | url: ajaxurl, 15 | data: data, 16 | dataType: 'json', 17 | type: 'POST', 18 | error: function() { 19 | 20 | }, 21 | success: function(response) { 22 | if(typeof response.success !== 'undefined') { 23 | if(response.success) { 24 | $t.parent().html(response.html); 25 | } 26 | else { 27 | $t.before(response.html); 28 | } 29 | } 30 | } 31 | }); 32 | }); 33 | 34 | 35 | $('#gravity_gc_form, #gravity_gc_project, #gravity_gc_template').on('change', function(e) { 36 | var $val = $(this).val(); 37 | if($val !== -1) { 38 | window.location.href = $val; 39 | } 40 | }); 41 | 42 | 43 | $('#gravity_gc_title_fields').on('change', function(e) { 44 | var $val = $(this).val(); 45 | 46 | $('.gc_row input[name^="gravity_gc[title][lengths]"]').closest('.gc_row').hide(); 47 | 48 | if($val) { 49 | for(var i=0,il = $val.length; i \ 14 | GC_USER_NAME= \ 15 | GC_PROJECT_ID= \ 16 | php export.php 17 | ``` 18 | 19 | You should see a file, `items.csv` once finished. -------------------------------------------------------------------------------- /06-export-report-to-csv/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "guzzlehttp/guzzle": "^6.5", 4 | "league/csv": "^9.6", 5 | "ext-json": "*" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /06-export-report-to-csv/composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "557fc77e36048607dfd5c0b811d0c191", 8 | "packages": [ 9 | { 10 | "name": "guzzlehttp/guzzle", 11 | "version": "6.5.4", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/guzzle/guzzle.git", 15 | "reference": "a4a1b6930528a8f7ee03518e6442ec7a44155d9d" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/guzzle/guzzle/zipball/a4a1b6930528a8f7ee03518e6442ec7a44155d9d", 20 | "reference": "a4a1b6930528a8f7ee03518e6442ec7a44155d9d", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "ext-json": "*", 25 | "guzzlehttp/promises": "^1.0", 26 | "guzzlehttp/psr7": "^1.6.1", 27 | "php": ">=5.5", 28 | "symfony/polyfill-intl-idn": "1.17.0" 29 | }, 30 | "require-dev": { 31 | "ext-curl": "*", 32 | "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", 33 | "psr/log": "^1.1" 34 | }, 35 | "suggest": { 36 | "psr/log": "Required for using the Log middleware" 37 | }, 38 | "type": "library", 39 | "extra": { 40 | "branch-alias": { 41 | "dev-master": "6.5-dev" 42 | } 43 | }, 44 | "autoload": { 45 | "psr-4": { 46 | "GuzzleHttp\\": "src/" 47 | }, 48 | "files": [ 49 | "src/functions_include.php" 50 | ] 51 | }, 52 | "notification-url": "https://packagist.org/downloads/", 53 | "license": [ 54 | "MIT" 55 | ], 56 | "authors": [ 57 | { 58 | "name": "Michael Dowling", 59 | "email": "mtdowling@gmail.com", 60 | "homepage": "https://github.com/mtdowling" 61 | } 62 | ], 63 | "description": "Guzzle is a PHP HTTP client library", 64 | "homepage": "http://guzzlephp.org/", 65 | "keywords": [ 66 | "client", 67 | "curl", 68 | "framework", 69 | "http", 70 | "http client", 71 | "rest", 72 | "web service" 73 | ], 74 | "time": "2020-05-25T19:35:05+00:00" 75 | }, 76 | { 77 | "name": "guzzlehttp/promises", 78 | "version": "v1.3.1", 79 | "source": { 80 | "type": "git", 81 | "url": "https://github.com/guzzle/promises.git", 82 | "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" 83 | }, 84 | "dist": { 85 | "type": "zip", 86 | "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", 87 | "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", 88 | "shasum": "" 89 | }, 90 | "require": { 91 | "php": ">=5.5.0" 92 | }, 93 | "require-dev": { 94 | "phpunit/phpunit": "^4.0" 95 | }, 96 | "type": "library", 97 | "extra": { 98 | "branch-alias": { 99 | "dev-master": "1.4-dev" 100 | } 101 | }, 102 | "autoload": { 103 | "psr-4": { 104 | "GuzzleHttp\\Promise\\": "src/" 105 | }, 106 | "files": [ 107 | "src/functions_include.php" 108 | ] 109 | }, 110 | "notification-url": "https://packagist.org/downloads/", 111 | "license": [ 112 | "MIT" 113 | ], 114 | "authors": [ 115 | { 116 | "name": "Michael Dowling", 117 | "email": "mtdowling@gmail.com", 118 | "homepage": "https://github.com/mtdowling" 119 | } 120 | ], 121 | "description": "Guzzle promises library", 122 | "keywords": [ 123 | "promise" 124 | ], 125 | "time": "2016-12-20T10:07:11+00:00" 126 | }, 127 | { 128 | "name": "guzzlehttp/psr7", 129 | "version": "1.6.1", 130 | "source": { 131 | "type": "git", 132 | "url": "https://github.com/guzzle/psr7.git", 133 | "reference": "239400de7a173fe9901b9ac7c06497751f00727a" 134 | }, 135 | "dist": { 136 | "type": "zip", 137 | "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", 138 | "reference": "239400de7a173fe9901b9ac7c06497751f00727a", 139 | "shasum": "" 140 | }, 141 | "require": { 142 | "php": ">=5.4.0", 143 | "psr/http-message": "~1.0", 144 | "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" 145 | }, 146 | "provide": { 147 | "psr/http-message-implementation": "1.0" 148 | }, 149 | "require-dev": { 150 | "ext-zlib": "*", 151 | "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" 152 | }, 153 | "suggest": { 154 | "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" 155 | }, 156 | "type": "library", 157 | "extra": { 158 | "branch-alias": { 159 | "dev-master": "1.6-dev" 160 | } 161 | }, 162 | "autoload": { 163 | "psr-4": { 164 | "GuzzleHttp\\Psr7\\": "src/" 165 | }, 166 | "files": [ 167 | "src/functions_include.php" 168 | ] 169 | }, 170 | "notification-url": "https://packagist.org/downloads/", 171 | "license": [ 172 | "MIT" 173 | ], 174 | "authors": [ 175 | { 176 | "name": "Michael Dowling", 177 | "email": "mtdowling@gmail.com", 178 | "homepage": "https://github.com/mtdowling" 179 | }, 180 | { 181 | "name": "Tobias Schultze", 182 | "homepage": "https://github.com/Tobion" 183 | } 184 | ], 185 | "description": "PSR-7 message implementation that also provides common utility methods", 186 | "keywords": [ 187 | "http", 188 | "message", 189 | "psr-7", 190 | "request", 191 | "response", 192 | "stream", 193 | "uri", 194 | "url" 195 | ], 196 | "time": "2019-07-01T23:21:34+00:00" 197 | }, 198 | { 199 | "name": "league/csv", 200 | "version": "9.6.0", 201 | "source": { 202 | "type": "git", 203 | "url": "https://github.com/thephpleague/csv.git", 204 | "reference": "7351a74625601914409b42b32cabb91a93773b7b" 205 | }, 206 | "dist": { 207 | "type": "zip", 208 | "url": "https://api.github.com/repos/thephpleague/csv/zipball/7351a74625601914409b42b32cabb91a93773b7b", 209 | "reference": "7351a74625601914409b42b32cabb91a93773b7b", 210 | "shasum": "" 211 | }, 212 | "require": { 213 | "ext-json": "*", 214 | "ext-mbstring": "*", 215 | "php": "^7.2.5" 216 | }, 217 | "require-dev": { 218 | "ext-curl": "*", 219 | "friendsofphp/php-cs-fixer": "^2.16", 220 | "phpstan/phpstan": "^0.12.0", 221 | "phpstan/phpstan-phpunit": "^0.12.0", 222 | "phpstan/phpstan-strict-rules": "^0.12.0", 223 | "phpunit/phpunit": "^8.0" 224 | }, 225 | "suggest": { 226 | "ext-dom": "Required to use the XMLConverter and or the HTMLConverter classes", 227 | "ext-iconv": "Needed to ease transcoding CSV using iconv stream filters" 228 | }, 229 | "type": "library", 230 | "extra": { 231 | "branch-alias": { 232 | "dev-master": "9.x-dev" 233 | } 234 | }, 235 | "autoload": { 236 | "psr-4": { 237 | "League\\Csv\\": "src" 238 | }, 239 | "files": [ 240 | "src/functions_include.php" 241 | ] 242 | }, 243 | "notification-url": "https://packagist.org/downloads/", 244 | "license": [ 245 | "MIT" 246 | ], 247 | "authors": [ 248 | { 249 | "name": "Ignace Nyamagana Butera", 250 | "email": "nyamsprod@gmail.com", 251 | "homepage": "https://github.com/nyamsprod/", 252 | "role": "Developer" 253 | } 254 | ], 255 | "description": "CSV data manipulation made easy in PHP", 256 | "homepage": "http://csv.thephpleague.com", 257 | "keywords": [ 258 | "convert", 259 | "csv", 260 | "export", 261 | "filter", 262 | "import", 263 | "read", 264 | "transform", 265 | "write" 266 | ], 267 | "funding": [ 268 | { 269 | "url": "https://github.com/sponsors/nyamsprod", 270 | "type": "github" 271 | } 272 | ], 273 | "time": "2020-03-17T15:15:35+00:00" 274 | }, 275 | { 276 | "name": "psr/http-message", 277 | "version": "1.0.1", 278 | "source": { 279 | "type": "git", 280 | "url": "https://github.com/php-fig/http-message.git", 281 | "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" 282 | }, 283 | "dist": { 284 | "type": "zip", 285 | "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", 286 | "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", 287 | "shasum": "" 288 | }, 289 | "require": { 290 | "php": ">=5.3.0" 291 | }, 292 | "type": "library", 293 | "extra": { 294 | "branch-alias": { 295 | "dev-master": "1.0.x-dev" 296 | } 297 | }, 298 | "autoload": { 299 | "psr-4": { 300 | "Psr\\Http\\Message\\": "src/" 301 | } 302 | }, 303 | "notification-url": "https://packagist.org/downloads/", 304 | "license": [ 305 | "MIT" 306 | ], 307 | "authors": [ 308 | { 309 | "name": "PHP-FIG", 310 | "homepage": "http://www.php-fig.org/" 311 | } 312 | ], 313 | "description": "Common interface for HTTP messages", 314 | "homepage": "https://github.com/php-fig/http-message", 315 | "keywords": [ 316 | "http", 317 | "http-message", 318 | "psr", 319 | "psr-7", 320 | "request", 321 | "response" 322 | ], 323 | "time": "2016-08-06T14:39:51+00:00" 324 | }, 325 | { 326 | "name": "ralouphie/getallheaders", 327 | "version": "3.0.3", 328 | "source": { 329 | "type": "git", 330 | "url": "https://github.com/ralouphie/getallheaders.git", 331 | "reference": "120b605dfeb996808c31b6477290a714d356e822" 332 | }, 333 | "dist": { 334 | "type": "zip", 335 | "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", 336 | "reference": "120b605dfeb996808c31b6477290a714d356e822", 337 | "shasum": "" 338 | }, 339 | "require": { 340 | "php": ">=5.6" 341 | }, 342 | "require-dev": { 343 | "php-coveralls/php-coveralls": "^2.1", 344 | "phpunit/phpunit": "^5 || ^6.5" 345 | }, 346 | "type": "library", 347 | "autoload": { 348 | "files": [ 349 | "src/getallheaders.php" 350 | ] 351 | }, 352 | "notification-url": "https://packagist.org/downloads/", 353 | "license": [ 354 | "MIT" 355 | ], 356 | "authors": [ 357 | { 358 | "name": "Ralph Khattar", 359 | "email": "ralph.khattar@gmail.com" 360 | } 361 | ], 362 | "description": "A polyfill for getallheaders.", 363 | "time": "2019-03-08T08:55:37+00:00" 364 | }, 365 | { 366 | "name": "symfony/polyfill-intl-idn", 367 | "version": "v1.17.0", 368 | "source": { 369 | "type": "git", 370 | "url": "https://github.com/symfony/polyfill-intl-idn.git", 371 | "reference": "3bff59ea7047e925be6b7f2059d60af31bb46d6a" 372 | }, 373 | "dist": { 374 | "type": "zip", 375 | "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/3bff59ea7047e925be6b7f2059d60af31bb46d6a", 376 | "reference": "3bff59ea7047e925be6b7f2059d60af31bb46d6a", 377 | "shasum": "" 378 | }, 379 | "require": { 380 | "php": ">=5.3.3", 381 | "symfony/polyfill-mbstring": "^1.3", 382 | "symfony/polyfill-php72": "^1.10" 383 | }, 384 | "suggest": { 385 | "ext-intl": "For best performance" 386 | }, 387 | "type": "library", 388 | "extra": { 389 | "branch-alias": { 390 | "dev-master": "1.17-dev" 391 | } 392 | }, 393 | "autoload": { 394 | "psr-4": { 395 | "Symfony\\Polyfill\\Intl\\Idn\\": "" 396 | }, 397 | "files": [ 398 | "bootstrap.php" 399 | ] 400 | }, 401 | "notification-url": "https://packagist.org/downloads/", 402 | "license": [ 403 | "MIT" 404 | ], 405 | "authors": [ 406 | { 407 | "name": "Laurent Bassin", 408 | "email": "laurent@bassin.info" 409 | }, 410 | { 411 | "name": "Symfony Community", 412 | "homepage": "https://symfony.com/contributors" 413 | } 414 | ], 415 | "description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions", 416 | "homepage": "https://symfony.com", 417 | "keywords": [ 418 | "compatibility", 419 | "idn", 420 | "intl", 421 | "polyfill", 422 | "portable", 423 | "shim" 424 | ], 425 | "funding": [ 426 | { 427 | "url": "https://symfony.com/sponsor", 428 | "type": "custom" 429 | }, 430 | { 431 | "url": "https://github.com/fabpot", 432 | "type": "github" 433 | }, 434 | { 435 | "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 436 | "type": "tidelift" 437 | } 438 | ], 439 | "time": "2020-05-12T16:47:27+00:00" 440 | }, 441 | { 442 | "name": "symfony/polyfill-mbstring", 443 | "version": "v1.17.0", 444 | "source": { 445 | "type": "git", 446 | "url": "https://github.com/symfony/polyfill-mbstring.git", 447 | "reference": "fa79b11539418b02fc5e1897267673ba2c19419c" 448 | }, 449 | "dist": { 450 | "type": "zip", 451 | "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fa79b11539418b02fc5e1897267673ba2c19419c", 452 | "reference": "fa79b11539418b02fc5e1897267673ba2c19419c", 453 | "shasum": "" 454 | }, 455 | "require": { 456 | "php": ">=5.3.3" 457 | }, 458 | "suggest": { 459 | "ext-mbstring": "For best performance" 460 | }, 461 | "type": "library", 462 | "extra": { 463 | "branch-alias": { 464 | "dev-master": "1.17-dev" 465 | } 466 | }, 467 | "autoload": { 468 | "psr-4": { 469 | "Symfony\\Polyfill\\Mbstring\\": "" 470 | }, 471 | "files": [ 472 | "bootstrap.php" 473 | ] 474 | }, 475 | "notification-url": "https://packagist.org/downloads/", 476 | "license": [ 477 | "MIT" 478 | ], 479 | "authors": [ 480 | { 481 | "name": "Nicolas Grekas", 482 | "email": "p@tchwork.com" 483 | }, 484 | { 485 | "name": "Symfony Community", 486 | "homepage": "https://symfony.com/contributors" 487 | } 488 | ], 489 | "description": "Symfony polyfill for the Mbstring extension", 490 | "homepage": "https://symfony.com", 491 | "keywords": [ 492 | "compatibility", 493 | "mbstring", 494 | "polyfill", 495 | "portable", 496 | "shim" 497 | ], 498 | "funding": [ 499 | { 500 | "url": "https://symfony.com/sponsor", 501 | "type": "custom" 502 | }, 503 | { 504 | "url": "https://github.com/fabpot", 505 | "type": "github" 506 | }, 507 | { 508 | "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 509 | "type": "tidelift" 510 | } 511 | ], 512 | "time": "2020-05-12T16:47:27+00:00" 513 | }, 514 | { 515 | "name": "symfony/polyfill-php72", 516 | "version": "v1.17.0", 517 | "source": { 518 | "type": "git", 519 | "url": "https://github.com/symfony/polyfill-php72.git", 520 | "reference": "f048e612a3905f34931127360bdd2def19a5e582" 521 | }, 522 | "dist": { 523 | "type": "zip", 524 | "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/f048e612a3905f34931127360bdd2def19a5e582", 525 | "reference": "f048e612a3905f34931127360bdd2def19a5e582", 526 | "shasum": "" 527 | }, 528 | "require": { 529 | "php": ">=5.3.3" 530 | }, 531 | "type": "library", 532 | "extra": { 533 | "branch-alias": { 534 | "dev-master": "1.17-dev" 535 | } 536 | }, 537 | "autoload": { 538 | "psr-4": { 539 | "Symfony\\Polyfill\\Php72\\": "" 540 | }, 541 | "files": [ 542 | "bootstrap.php" 543 | ] 544 | }, 545 | "notification-url": "https://packagist.org/downloads/", 546 | "license": [ 547 | "MIT" 548 | ], 549 | "authors": [ 550 | { 551 | "name": "Nicolas Grekas", 552 | "email": "p@tchwork.com" 553 | }, 554 | { 555 | "name": "Symfony Community", 556 | "homepage": "https://symfony.com/contributors" 557 | } 558 | ], 559 | "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", 560 | "homepage": "https://symfony.com", 561 | "keywords": [ 562 | "compatibility", 563 | "polyfill", 564 | "portable", 565 | "shim" 566 | ], 567 | "funding": [ 568 | { 569 | "url": "https://symfony.com/sponsor", 570 | "type": "custom" 571 | }, 572 | { 573 | "url": "https://github.com/fabpot", 574 | "type": "github" 575 | }, 576 | { 577 | "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 578 | "type": "tidelift" 579 | } 580 | ], 581 | "time": "2020-05-12T16:47:27+00:00" 582 | } 583 | ], 584 | "packages-dev": [], 585 | "aliases": [], 586 | "minimum-stability": "stable", 587 | "stability-flags": [], 588 | "prefer-stable": false, 589 | "prefer-lowest": false, 590 | "platform": { 591 | "ext-json": "*" 592 | }, 593 | "platform-dev": [], 594 | "plugin-api-version": "1.1.0" 595 | } 596 | -------------------------------------------------------------------------------- /06-export-report-to-csv/export.php: -------------------------------------------------------------------------------- 1 | 'https://api.gathercontent.com', 16 | 'headers' => [ 17 | 'Accept' => 'application/vnd.gathercontent.v2+json' 18 | ], 19 | 'auth' => [ 20 | $username, 21 | $apikey 22 | ] 23 | ]); 24 | 25 | // Create the CSV File 26 | touch('items.csv'); 27 | $csv = Writer::createFromPath('items.csv'); 28 | 29 | // Insert header row 30 | $csv->insertOne(['Title', 'Assignee(s)', 'Template', 'Folder', 'Workflow Status', 'Due Date']); 31 | 32 | function insertItem($item): void { 33 | global $csv; 34 | $csv->insertOne([$item->name, join(",\n", $item->assignee_full_names), $item->template_name, $item->folder_name, $item->status_name, $item->next_due_at]); 35 | } 36 | 37 | // @link https://docs.gathercontent.com/reference#listitems 38 | $listItemsPage1 = $gc->get("projects/{$projectId}/items?include=template_name,assignee_full_names,folder_name,status_name,item_url"); 39 | 40 | $response = json_decode($listItemsPage1->getBody()); 41 | $totalPages = $response->pagination->total_pages; 42 | 43 | array_walk($response->data, 'insertItem'); 44 | 45 | if ($totalPages > 1) { 46 | foreach (range(2, $totalPages) as $page) { 47 | $response = $gc->get("projects/{$projectId}/items?include=template_name,assignee_full_names,folder_name,status_name,item_url&page={$page}"); 48 | $response = json_decode($response->getBody()); 49 | array_walk($response->data, 'insertItem'); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GatherContent API Examples 2 | 3 | This repository contains multiple examples using the GatherContent API. 4 | 5 | Please see our [API Documentation](https://gathercontent.com/developers/) for more information. 6 | 7 | ## Credentials 8 | 9 | Each of these examples require your username and an API Key. You can generate an API Key within your Personal Settings. 10 | -------------------------------------------------------------------------------- /Test CSV file.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bynder/gathercontent-api-examples/2b794b86ac3c5bc9aef22870adc9abd15d199bbd/Test CSV file.zip --------------------------------------------------------------------------------