├── .gitignore ├── README.md ├── composer.json ├── composer.lock ├── examples ├── environment.example.php └── example.php └── src ├── ClientFactory.php └── simplecast-api.php /.gitignore: -------------------------------------------------------------------------------- 1 | environment.php 2 | vendor/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simplecast PHP SDK 2 | A PHP SDK wrapper around the [Simplecast.fm API](https://api.simplecast.fm/). 3 | 4 | ## Installation 5 | *Simplecast* is available on Packagist as the [tightenco/simplecast](https://packagist.org/packages/tightenco/simplecast) package. 6 | 7 | ## Quickstart 8 | ```php 9 | 'your api key here' 14 | ]); 15 | 16 | $result = $simplecast->podcasts(); 17 | 18 | var_dump($result); 19 | ``` 20 | 21 | ## Available methods 22 | Each of these methods is available on the client (shown in the example above as `$simplecast`). 23 | 24 | ### podcasts 25 | Shows a list of all of your podcasts that are hosted by Simplecast. 26 | 27 | ```php 28 | $result = $simplecast->podcasts(); 29 | ``` 30 | 31 | ``` 32 | array(2) { 33 | [0]=> 34 | array(15) { 35 | ["id"]=> 36 | int(335) 37 | ["title"]=> 38 | string(25) "The Five-Minute Geek Show" 39 | ["rss_url"]=> 40 | string(37) "http://simplecast.fm/podcasts/335/rss" 41 | ["description"]=> 42 | string(125) "Matt Stauffer, unabashedly geeky, 5 minutes, twice a week. Frontend dev, backend dev, audio, design, podcasts--all fair game." 43 | ["author"]=> 44 | string(13) "Matt Stauffer" 45 | ["copyright"]=> 46 | string(19) "All rights reserved" 47 | ["keywords"]=> 48 | string(92) "geek, technology, php, css, fiveminutegeekshow, it, programming, development, design, ui, ux" 49 | ["subdomain"]=> 50 | string(18) "fiveminutegeekshow" 51 | ["categories"]=> 52 | array(3) { 53 | [0]=> 54 | string(10) "Technology" 55 | [1]=> 56 | string(24) "Technology :: Podcasting" 57 | [2]=> 58 | string(23) "Technology :: Tech News" 59 | } 60 | ["itunes_url"]=> 61 | string(73) "https://itunes.apple.com/us/podcast/the-five-minute-geek-show/id952727637" 62 | ["language"]=> 63 | string(2) "en" 64 | ["website"]=> 65 | string(30) "http://fiveminutegeekshow.com/" 66 | ["twitter"]=> 67 | string(15) "5minutegeekshow" 68 | ["explicit"]=> 69 | bool(false) 70 | ["images"]=> 71 | array(3) { 72 | ["large"]=> 73 | string(82) "https://simplecast-media.s3.amazonaws.com/podcast/image/335/1419886609-artwork.jpg" 74 | ["small"]=> 75 | string(88) "https://simplecast-media.s3.amazonaws.com/podcast/image/335/small_1419886609-artwork.jpg" 76 | ["thumb"]=> 77 | string(88) "https://simplecast-media.s3.amazonaws.com/podcast/image/335/thumb_1419886609-artwork.jpg" 78 | } 79 | }, 80 | [1] => 81 | array(15) { 82 | ... 83 | } 84 | } 85 | ``` 86 | 87 | ### podcast 88 | Shows full data for a single podcast given its `podcast_id`. 89 | 90 | ```php 91 | $result = $simplecast->podcast([ 92 | 'podcast_id' => 335 93 | ]); 94 | ``` 95 | 96 | ``` 97 | array(15) { 98 | ["id"]=> 99 | int(335) 100 | ["title"]=> 101 | string(25) "The Five-Minute Geek Show" 102 | ["rss_url"]=> 103 | string(37) "http://simplecast.fm/podcasts/335/rss" 104 | ["description"]=> 105 | string(125) "Matt Stauffer, unabashedly geeky, 5 minutes, twice a week. Frontend dev, backend dev, audio, design, podcasts--all fair game." 106 | ["author"]=> 107 | string(13) "Matt Stauffer" 108 | ["copyright"]=> 109 | string(19) "All rights reserved" 110 | ["keywords"]=> 111 | string(92) "geek, technology, php, css, fiveminutegeekshow, it, programming, development, design, ui, ux" 112 | ["subdomain"]=> 113 | string(18) "fiveminutegeekshow" 114 | ["categories"]=> 115 | array(3) { 116 | [0]=> 117 | string(10) "Technology" 118 | [1]=> 119 | string(24) "Technology :: Podcasting" 120 | [2]=> 121 | string(23) "Technology :: Tech News" 122 | } 123 | ["itunes_url"]=> 124 | string(73) "https://itunes.apple.com/us/podcast/the-five-minute-geek-show/id952727637" 125 | ["language"]=> 126 | string(2) "en" 127 | ["website"]=> 128 | string(30) "http://fiveminutegeekshow.com/" 129 | ["twitter"]=> 130 | string(15) "5minutegeekshow" 131 | ["explicit"]=> 132 | bool(false) 133 | ["images"]=> 134 | array(3) { 135 | ["large"]=> 136 | string(82) "https://simplecast-media.s3.amazonaws.com/podcast/image/335/1419886609-artwork.jpg" 137 | ["small"]=> 138 | string(88) "https://simplecast-media.s3.amazonaws.com/podcast/image/335/small_1419886609-artwork.jpg" 139 | ["thumb"]=> 140 | string(88) "https://simplecast-media.s3.amazonaws.com/podcast/image/335/thumb_1419886609-artwork.jpg" 141 | } 142 | } 143 | ``` 144 | 145 | ### podcastEpisodes 146 | Lists all episodes of a podcast given its `podcast_id`. 147 | 148 | ```php 149 | $result = $simplecast->podcastEpisodes([ 150 | 'podcast_id' => 335 151 | ]); 152 | ``` 153 | 154 | ``` 155 | array(38) { 156 | [0]=> 157 | array(15) { 158 | ["id"]=> 159 | int(11265) 160 | ["number"]=> 161 | int(38) 162 | ["podcast_id"]=> 163 | int(335) 164 | ["guid"]=> 165 | string(36) "2cdb9817-3af1-486b-b9f8-055ca29c7cc8" 166 | ["title"]=> 167 | string(38) "38 | How to Make Remote Work Suck Less" 168 | ["duration"]=> 169 | int(454) 170 | ["explicit"]=> 171 | bool(false) 172 | ["published"]=> 173 | bool(true) 174 | ["description"]=> 175 | string(102) "Everyone's in love with remote work. So are we! But there are some big pains that come along with it. " 176 | ["long_description"]=> 177 | string(341) "Everyone's in love with remote work. So are we! But there are some big pains that come along with it. 178 | 179 | - [REMOTE](http://www.amazon.com/Remote-Office-Required-Jason-Fried/dp/0804137501) 180 | - [Campfire](https://campfirenow.com/) 181 | - [Slack](https://slack.com/) 182 | - [Sqwiggle](https://www.sqwiggle.com/) 183 | - [Screenhero](https://screenhero.com/)" 184 | ["published_at"]=> 185 | string(24) "2015-05-07T18:55:00.000Z" 186 | ["audio_file_size"]=> 187 | int(3699203) 188 | ["audio_url"]=> 189 | string(36) "http://audio.simplecast.fm/11265.mp3" 190 | ["sharing_url"]=> 191 | string(32) "https://simplecast.fm/s/777e7a43" 192 | ["images"]=> 193 | array(3) { 194 | ["large"]=> 195 | string(84) "https://simplecast-media.s3.amazonaws.com/episode/image/11265/1431025516-artwork.jpg" 196 | ["small"]=> 197 | string(90) "https://simplecast-media.s3.amazonaws.com/episode/image/11265/small_1431025516-artwork.jpg" 198 | ["thumb"]=> 199 | string(90) "https://simplecast-media.s3.amazonaws.com/episode/image/11265/thumb_1431025516-artwork.jpg" 200 | } 201 | } 202 | [1]=> 203 | array(15) { 204 | .. 205 | }, 206 | .. 207 | } 208 | ``` 209 | 210 | ### podcastEpisode 211 | Shows the data for a podcast episode given its `podcast_id` and `episode_id`. 212 | 213 | ```php 214 | $result = $simplecast->podcastEpisode([ 215 | 'podcast_id' => 335, 216 | 'episode_id' => 11265 217 | ]); 218 | ``` 219 | 220 | ``` 221 | array(15) { 222 | ["id"]=> 223 | int(11265) 224 | ["number"]=> 225 | int(38) 226 | ["podcast_id"]=> 227 | int(335) 228 | ["guid"]=> 229 | string(36) "2cdb9817-3af1-486b-b9f8-055ca29c7cc8" 230 | ["title"]=> 231 | string(38) "38 | How to Make Remote Work Suck Less" 232 | ["duration"]=> 233 | int(454) 234 | ["explicit"]=> 235 | bool(false) 236 | ["published"]=> 237 | bool(true) 238 | ["description"]=> 239 | string(102) "Everyone's in love with remote work. So are we! But there are some big pains that come along with it. " 240 | ["long_description"]=> 241 | string(341) "Everyone's in love with remote work. So are we! But there are some big pains that come along with it. 242 | 243 | - [REMOTE](http://www.amazon.com/Remote-Office-Required-Jason-Fried/dp/0804137501) 244 | - [Campfire](https://campfirenow.com/) 245 | - [Slack](https://slack.com/) 246 | - [Sqwiggle](https://www.sqwiggle.com/) 247 | - [Screenhero](https://screenhero.com/)" 248 | ["published_at"]=> 249 | string(29) "2015-05-07T14:55:00.000-04:00" 250 | ["audio_file_size"]=> 251 | int(3699203) 252 | ["audio_url"]=> 253 | string(36) "http://audio.simplecast.fm/11265.mp3" 254 | ["sharing_url"]=> 255 | string(32) "https://simplecast.fm/s/777e7a43" 256 | ["images"]=> 257 | array(3) { 258 | ["large"]=> 259 | string(84) "https://simplecast-media.s3.amazonaws.com/episode/image/11265/1431025516-artwork.jpg" 260 | ["small"]=> 261 | string(90) "https://simplecast-media.s3.amazonaws.com/episode/image/11265/small_1431025516-artwork.jpg" 262 | ["thumb"]=> 263 | string(90) "https://simplecast-media.s3.amazonaws.com/episode/image/11265/thumb_1431025516-artwork.jpg" 264 | } 265 | } 266 | ``` 267 | 268 | ### podcastEpisodeEmbed 269 | Get the audio player embed code for a podcast episode given its `podcast_id` and `episode_id`. 270 | 271 | ```php 272 | $result = $simplecast->podcastEpisodeEmbed([ 273 | 'podcast_id' => 335, 274 | 'episode_id' => 11265 275 | ]); 276 | ``` 277 | 278 | ``` 279 | array(5) { 280 | ["id"]=> 281 | int(11265) 282 | ["title"]=> 283 | string(38) "38 | How to Make Remote Work Suck Less" 284 | ["height"]=> 285 | int(36) 286 | ["width"]=> 287 | NULL 288 | ["html"]=> 289 | array(2) { 290 | ["light"]=> 291 | string(132) "" 292 | ["dark"]=> 293 | string(131) "" 294 | } 295 | } 296 | ``` 297 | 298 | ### podcastEpisodeStatistics 299 | Lists the statistics for a podcast episode given its `podcast_id`, `episode_id`, and a period of time. 300 | 301 | ```php 302 | $result = $simplecast->podcastEpisodeStatistics([ 303 | 'podcast_id' => 335, 304 | 'episode_id' => 11265, 305 | 'timeframe' => 'custom', 306 | 'start_date' => '2015-05-09', 307 | 'end_date' => '2015-05-10' 308 | ]); 309 | ``` 310 | 311 | Options for `timeframe` are: `recent`, `year`, `all`, `custom`. Note that `custom` timeframes require two more parameters, `start_date` and `end_date`, both formatted as `YYYY-MM-DD`. 312 | 313 | ``` 314 | array(2) { 315 | ["data"]=> 316 | array(2) { 317 | [0]=> 318 | array(2) { 319 | ["date"]=> 320 | string(10) "05-09-2015" 321 | ["listens"]=> 322 | int(12345) 323 | } 324 | [1]=> 325 | array(2) { 326 | ["date"]=> 327 | string(10) "05-10-2015" 328 | ["listens"]=> 329 | int(42) 330 | } 331 | } 332 | ["total_listens"]=> 333 | int(12387) 334 | } 335 | ``` 336 | 337 | ### podcastStatistics 338 | Show statistics for the podcast. 339 | 340 | ```php 341 | $result = $simplecast->podcastStatistics([ 342 | 'podcast_id' => 335 343 | ]); 344 | ``` 345 | 346 | ``` 347 | array(2) { 348 | ["total_listens"]=> 349 | int(1234567890) 350 | ["since"]=> 351 | string(10) "12-16-2014" 352 | } 353 | ``` 354 | 355 | ### podcastStatisticsOverall 356 | Shows statistics for the podcast, scoped by time. 357 | 358 | ```php 359 | $result = $simplecast->podcastStatisticsOverall([ 360 | 'podcast_id' => 335, 361 | 'timeframe' => 'recent' 362 | ]); 363 | ``` 364 | 365 | Options for `timeframe` are: `recent`, `year`, `all`, `custom`. Note that `custom` timeframes require two more parameters, `start_date` and `end_date`, both formatted as `YYYY-MM-DD`. 366 | 367 | ``` 368 | array(2) { 369 | ["data"]=> 370 | array(22) { 371 | [0]=> 372 | array(2) { 373 | ["date"]=> 374 | string(10) "04-19-2015" 375 | ["listens"]=> 376 | int(12345) 377 | }, 378 | ... 379 | [21]=> 380 | array(2) { 381 | ["date"]=> 382 | string(10) "05-10-2015" 383 | ["listens"]=> 384 | int(54321) 385 | } 386 | } 387 | ["total_listens"]=> 388 | int(12345678) 389 | } 390 | ``` 391 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tightenco/simplecast", 3 | "type": "library", 4 | "description": "A Simplecast PHP SDK", 5 | "keywords": ["simplecast","podcast"], 6 | "license": "MIT", 7 | "require": { 8 | "guzzlehttp/guzzle-services": "0.5.*" 9 | }, 10 | "authors": [ 11 | { 12 | "name": "Matt Stauffer", 13 | "homepage": "http://tighten.co/", 14 | "email": "matt@tighten.co", 15 | "role": "Developer" 16 | } 17 | ], 18 | "autoload": { 19 | "psr-4": { 20 | "Simplecast\\": "src/" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "2920ea8da46f91aa69afff54c5e49dfe", 8 | "packages": [ 9 | { 10 | "name": "guzzlehttp/command", 11 | "version": "0.7.1", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/guzzle/command.git", 15 | "reference": "2e8286ff81f75f97b00f7dcc2f51e2efafb373bd" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/guzzle/command/zipball/2e8286ff81f75f97b00f7dcc2f51e2efafb373bd", 20 | "reference": "2e8286ff81f75f97b00f7dcc2f51e2efafb373bd", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "guzzlehttp/guzzle": "~5.0", 25 | "php": ">=5.4.0" 26 | }, 27 | "require-dev": { 28 | "phpunit/phpunit": "~4.0" 29 | }, 30 | "type": "library", 31 | "extra": { 32 | "branch-alias": { 33 | "dev-master": "0.7-dev" 34 | } 35 | }, 36 | "autoload": { 37 | "psr-4": { 38 | "GuzzleHttp\\Command\\": "src/" 39 | } 40 | }, 41 | "notification-url": "https://packagist.org/downloads/", 42 | "license": [ 43 | "MIT" 44 | ], 45 | "authors": [ 46 | { 47 | "name": "Michael Dowling", 48 | "email": "mtdowling@gmail.com", 49 | "homepage": "https://github.com/mtdowling" 50 | } 51 | ], 52 | "description": "Provides the foundation for building command based web service clients", 53 | "time": "2015-01-14 18:54:57" 54 | }, 55 | { 56 | "name": "guzzlehttp/guzzle", 57 | "version": "5.2.0", 58 | "source": { 59 | "type": "git", 60 | "url": "https://github.com/guzzle/guzzle.git", 61 | "reference": "475b29ccd411f2fa8a408e64576418728c032cfa" 62 | }, 63 | "dist": { 64 | "type": "zip", 65 | "url": "https://api.github.com/repos/guzzle/guzzle/zipball/475b29ccd411f2fa8a408e64576418728c032cfa", 66 | "reference": "475b29ccd411f2fa8a408e64576418728c032cfa", 67 | "shasum": "" 68 | }, 69 | "require": { 70 | "guzzlehttp/ringphp": "~1.0", 71 | "php": ">=5.4.0" 72 | }, 73 | "require-dev": { 74 | "ext-curl": "*", 75 | "phpunit/phpunit": "~4.0", 76 | "psr/log": "~1.0" 77 | }, 78 | "type": "library", 79 | "extra": { 80 | "branch-alias": { 81 | "dev-master": "5.0-dev" 82 | } 83 | }, 84 | "autoload": { 85 | "psr-4": { 86 | "GuzzleHttp\\": "src/" 87 | } 88 | }, 89 | "notification-url": "https://packagist.org/downloads/", 90 | "license": [ 91 | "MIT" 92 | ], 93 | "authors": [ 94 | { 95 | "name": "Michael Dowling", 96 | "email": "mtdowling@gmail.com", 97 | "homepage": "https://github.com/mtdowling" 98 | } 99 | ], 100 | "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", 101 | "homepage": "http://guzzlephp.org/", 102 | "keywords": [ 103 | "client", 104 | "curl", 105 | "framework", 106 | "http", 107 | "http client", 108 | "rest", 109 | "web service" 110 | ], 111 | "time": "2015-01-28 01:03:29" 112 | }, 113 | { 114 | "name": "guzzlehttp/guzzle-services", 115 | "version": "0.5.0", 116 | "source": { 117 | "type": "git", 118 | "url": "https://github.com/guzzle/guzzle-services.git", 119 | "reference": "5402867628d266748db88f05c90ede54fd1d884c" 120 | }, 121 | "dist": { 122 | "type": "zip", 123 | "url": "https://api.github.com/repos/guzzle/guzzle-services/zipball/5402867628d266748db88f05c90ede54fd1d884c", 124 | "reference": "5402867628d266748db88f05c90ede54fd1d884c", 125 | "shasum": "" 126 | }, 127 | "require": { 128 | "guzzlehttp/command": "0.7.*", 129 | "php": ">=5.4.0" 130 | }, 131 | "require-dev": { 132 | "phpunit/phpunit": "~4.0" 133 | }, 134 | "type": "library", 135 | "extra": { 136 | "branch-alias": { 137 | "dev-master": "0.4-dev" 138 | } 139 | }, 140 | "autoload": { 141 | "psr-4": { 142 | "GuzzleHttp\\Command\\Guzzle\\": "src/" 143 | } 144 | }, 145 | "notification-url": "https://packagist.org/downloads/", 146 | "license": [ 147 | "MIT" 148 | ], 149 | "authors": [ 150 | { 151 | "name": "Michael Dowling", 152 | "email": "mtdowling@gmail.com", 153 | "homepage": "https://github.com/mtdowling" 154 | } 155 | ], 156 | "description": "Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.", 157 | "time": "2014-12-23 19:13:18" 158 | }, 159 | { 160 | "name": "guzzlehttp/ringphp", 161 | "version": "1.0.7", 162 | "source": { 163 | "type": "git", 164 | "url": "https://github.com/guzzle/RingPHP.git", 165 | "reference": "52d868f13570a9a56e5fce6614e0ec75d0f13ac2" 166 | }, 167 | "dist": { 168 | "type": "zip", 169 | "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/52d868f13570a9a56e5fce6614e0ec75d0f13ac2", 170 | "reference": "52d868f13570a9a56e5fce6614e0ec75d0f13ac2", 171 | "shasum": "" 172 | }, 173 | "require": { 174 | "guzzlehttp/streams": "~3.0", 175 | "php": ">=5.4.0", 176 | "react/promise": "~2.0" 177 | }, 178 | "require-dev": { 179 | "ext-curl": "*", 180 | "phpunit/phpunit": "~4.0" 181 | }, 182 | "suggest": { 183 | "ext-curl": "Guzzle will use specific adapters if cURL is present" 184 | }, 185 | "type": "library", 186 | "extra": { 187 | "branch-alias": { 188 | "dev-master": "1.0-dev" 189 | } 190 | }, 191 | "autoload": { 192 | "psr-4": { 193 | "GuzzleHttp\\Ring\\": "src/" 194 | } 195 | }, 196 | "notification-url": "https://packagist.org/downloads/", 197 | "license": [ 198 | "MIT" 199 | ], 200 | "authors": [ 201 | { 202 | "name": "Michael Dowling", 203 | "email": "mtdowling@gmail.com", 204 | "homepage": "https://github.com/mtdowling" 205 | } 206 | ], 207 | "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.", 208 | "time": "2015-03-30 01:43:20" 209 | }, 210 | { 211 | "name": "guzzlehttp/streams", 212 | "version": "3.0.0", 213 | "source": { 214 | "type": "git", 215 | "url": "https://github.com/guzzle/streams.git", 216 | "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5" 217 | }, 218 | "dist": { 219 | "type": "zip", 220 | "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", 221 | "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", 222 | "shasum": "" 223 | }, 224 | "require": { 225 | "php": ">=5.4.0" 226 | }, 227 | "require-dev": { 228 | "phpunit/phpunit": "~4.0" 229 | }, 230 | "type": "library", 231 | "extra": { 232 | "branch-alias": { 233 | "dev-master": "3.0-dev" 234 | } 235 | }, 236 | "autoload": { 237 | "psr-4": { 238 | "GuzzleHttp\\Stream\\": "src/" 239 | } 240 | }, 241 | "notification-url": "https://packagist.org/downloads/", 242 | "license": [ 243 | "MIT" 244 | ], 245 | "authors": [ 246 | { 247 | "name": "Michael Dowling", 248 | "email": "mtdowling@gmail.com", 249 | "homepage": "https://github.com/mtdowling" 250 | } 251 | ], 252 | "description": "Provides a simple abstraction over streams of data", 253 | "homepage": "http://guzzlephp.org/", 254 | "keywords": [ 255 | "Guzzle", 256 | "stream" 257 | ], 258 | "time": "2014-10-12 19:18:40" 259 | }, 260 | { 261 | "name": "react/promise", 262 | "version": "v2.2.0", 263 | "source": { 264 | "type": "git", 265 | "url": "https://github.com/reactphp/promise.git", 266 | "reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef" 267 | }, 268 | "dist": { 269 | "type": "zip", 270 | "url": "https://api.github.com/repos/reactphp/promise/zipball/365fcee430dfa4ace1fbc75737ca60ceea7eeeef", 271 | "reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef", 272 | "shasum": "" 273 | }, 274 | "require": { 275 | "php": ">=5.4.0" 276 | }, 277 | "type": "library", 278 | "extra": { 279 | "branch-alias": { 280 | "dev-master": "2.0-dev" 281 | } 282 | }, 283 | "autoload": { 284 | "psr-4": { 285 | "React\\Promise\\": "src/" 286 | }, 287 | "files": [ 288 | "src/functions_include.php" 289 | ] 290 | }, 291 | "notification-url": "https://packagist.org/downloads/", 292 | "license": [ 293 | "MIT" 294 | ], 295 | "authors": [ 296 | { 297 | "name": "Jan Sorgalla", 298 | "email": "jsorgalla@googlemail.com" 299 | } 300 | ], 301 | "description": "A lightweight implementation of CommonJS Promises/A for PHP", 302 | "time": "2014-12-30 13:32:42" 303 | } 304 | ], 305 | "packages-dev": [], 306 | "aliases": [], 307 | "minimum-stability": "stable", 308 | "stability-flags": [], 309 | "prefer-stable": false, 310 | "prefer-lowest": false, 311 | "platform": [], 312 | "platform-dev": [] 313 | } 314 | -------------------------------------------------------------------------------- /examples/environment.example.php: -------------------------------------------------------------------------------- 1 | $apiKey 7 | ]); 8 | 9 | $result = $simplecast->podcasts(); 10 | 11 | // $result = $simplecast->podcast([ 12 | // 'podcast_id' => 335 13 | // ]); 14 | 15 | // $result = $simplecast->podcastEpisodes([ 16 | // 'podcast_id' => 335 17 | // ]); 18 | 19 | // $result = $simplecast->podcastEpisode([ 20 | // 'podcast_id' => 335, 21 | // 'episode_id' => 11265 22 | // ]); 23 | 24 | // $result = $simplecast->podcastEpisodeEmbed([ 25 | // 'podcast_id' => 335, 26 | // 'episode_id' => 11265 27 | // ]); 28 | 29 | // $result = $simplecast->podcastStatistics([ 30 | // 'podcast_id' => 335 31 | // ]); 32 | 33 | // $result = $simplecast->podcastStatisticsOverall([ 34 | // 'podcast_id' => 335 35 | // ]); 36 | 37 | // $result = $simplecast->podcastStatisticsOverall([ 38 | // 'podcast_id' => 335, 39 | // 'timeframe' => 'custom', 40 | // 'start_date' => '2015-01-01', 41 | // 'end_date' => '2015-01-30' 42 | // ]); 43 | 44 | // $result = $simplecast->podcastEpisodeStatistics([ 45 | // 'podcast_id' => 335, 46 | // 'episode_id' => 11265, 47 | // ]); 48 | 49 | echo '
';
50 | var_dump($result);
51 | 


--------------------------------------------------------------------------------
/src/ClientFactory.php:
--------------------------------------------------------------------------------
 1 |  [
17 |                 'headers' => [
18 |                     'X-API-KEY' => $config['apiKey']
19 |                 ]
20 |             ]
21 |         ], [], $config);
22 | 
23 |         $description = self::getDescriptionFromConfig($config);
24 | 
25 |         $guzzleClient = new GuzzleClient($client, $description);
26 | 
27 |         $guzzleClient->setConfig(
28 |             'defaults/api_version',
29 |             1
30 |         );
31 | 
32 |         return $guzzleClient;
33 |     }
34 | 
35 |     private static function getDescriptionFromConfig(array $config)
36 |     {
37 |         $data = isset($config['descriptionPath']) && is_readable($config['descriptionPath'])
38 |             ? include($config['descriptionPath'])
39 |             : include(__DIR__ . '/simplecast-api.php');
40 | 
41 |         return new Description($data);
42 |     }
43 | }
44 | 


--------------------------------------------------------------------------------
/src/simplecast-api.php:
--------------------------------------------------------------------------------
  1 |  'https://api.simplecast.fm/',
  3 |     'name' => 'Simplecast',
  4 |     'apiVersion' => 1,
  5 |     'operations' => [
  6 |         'podcasts' => [
  7 |             'httpMethod' => 'GET',
  8 |             'uri' => '/v{api_version}/podcasts.json',
  9 |             'responseModel' => 'getResponse',
 10 |             'parameters' => [
 11 |                 'api_version' => [
 12 |                     'required' => true,
 13 |                     'type'     => 'string',
 14 |                     'location' => 'uri',
 15 |                 ],
 16 |             ]
 17 |         ],
 18 |         'podcast' => [
 19 |             'httpMethod' => 'GET',
 20 |             'uri' => '/v{api_version}/podcasts/{podcast_id}.json',
 21 |             'responseModel' => 'getResponse',
 22 |             'parameters' => [
 23 |                 'api_version' => [
 24 |                     'required' => true,
 25 |                     'type'     => 'string',
 26 |                     'location' => 'uri',
 27 |                 ],
 28 |                 'podcast_id' => [
 29 |                     'location' => 'uri',
 30 |                     'type' => 'string'
 31 |                 ]
 32 |             ]
 33 |         ],
 34 |         'podcastEpisodes' => [
 35 |             'httpMethod' => 'GET',
 36 |             'uri' => '/v{api_version}/podcasts/{podcast_id}/episodes.json',
 37 |             'responseModel' => 'getResponse',
 38 |             'parameters' => [
 39 |                 'api_version' => [
 40 |                     'required' => true,
 41 |                     'type'     => 'string',
 42 |                     'location' => 'uri',
 43 |                 ],
 44 |                 'podcast_id' => [
 45 |                     'location' => 'uri',
 46 |                     'type' => 'string'
 47 |                 ]
 48 |             ]
 49 |         ],
 50 |         'podcastEpisode' => [
 51 |             'httpMethod' => 'GET',
 52 |             'uri' => '/v{api_version}/podcasts/{podcast_id}/episodes/{episode_id}.json',
 53 |             'responseModel' => 'getResponse',
 54 |             'parameters' => [
 55 |                 'api_version' => [
 56 |                     'required' => true,
 57 |                     'type'     => 'string',
 58 |                     'location' => 'uri',
 59 |                 ],
 60 |                 'podcast_id' => [
 61 |                     'location' => 'uri',
 62 |                     'type' => 'string'
 63 |                 ],
 64 |                 'episode_id' => [
 65 |                     'location' => 'uri',
 66 |                     'type' => 'string'
 67 |                 ]
 68 |             ]
 69 |         ],
 70 |         'podcastEpisodeEmbed' => [
 71 |             'httpMethod' => 'GET',
 72 |             'uri' => '/v{api_version}/podcasts/{podcast_id}/episodes/{episode_id}/embed.json',
 73 |             'responseModel' => 'getResponse',
 74 |             'parameters' => [
 75 |                 'api_version' => [
 76 |                     'required' => true,
 77 |                     'type'     => 'string',
 78 |                     'location' => 'uri',
 79 |                 ],
 80 |                 'podcast_id' => [
 81 |                     'location' => 'uri',
 82 |                     'type' => 'string'
 83 |                 ],
 84 |                 'episode_id' => [
 85 |                     'location' => 'uri',
 86 |                     'type' => 'string'
 87 |                 ]
 88 |             ]
 89 |         ],
 90 |         'podcastStatistics' => [
 91 |             'httpMethod' => 'GET',
 92 |             'uri' => '/v{api_version}/podcasts/{podcast_id}/statistics.json',
 93 |             'responseModel' => 'getResponse',
 94 |             'parameters' => [
 95 |                 'api_version' => [
 96 |                     'required' => true,
 97 |                     'type'     => 'string',
 98 |                     'location' => 'uri',
 99 |                 ],
100 |                 'podcast_id' => [
101 |                     'location' => 'uri',
102 |                     'type' => 'string'
103 |                 ]
104 |             ]
105 |         ],
106 |         'podcastStatisticsOverall' => [
107 |             'httpMethod' => 'GET',
108 |             'uri' => '/v{api_version}/podcasts/{podcast_id}/statistics/overall.json',
109 |             'responseModel' => 'getResponse',
110 |             'parameters' => [
111 |                 'api_version' => [
112 |                     'required' => true,
113 |                     'type'     => 'string',
114 |                     'location' => 'uri',
115 |                 ],
116 |                 'podcast_id' => [
117 |                     'location' => 'uri',
118 |                     'type' => 'string'
119 |                 ],
120 |                 'timeframe' => [
121 |                     'location' => 'query',
122 |                     'type' => 'string', // recent, year, all, custom
123 |                 ],
124 |                 'start_date' => [
125 |                     'location' => 'query',
126 |                     'type' => 'string', // YYYY-MM-DD
127 |                 ],
128 |                 'end_date' => [
129 |                     'location' => 'query',
130 |                     'type' => 'string', // YYYY-MM-DD
131 |                 ],
132 |             ]
133 |         ],
134 |         'podcastEpisodeStatistics' => [
135 |             'httpMethod' => 'GET',
136 |             'uri' => '/v{api_version}/podcasts/{podcast_id}/statistics/episode.json',
137 |             'responseModel' => 'getResponse',
138 |             'parameters' => [
139 |                 'api_version' => [
140 |                     'required' => true,
141 |                     'type'     => 'string',
142 |                     'location' => 'uri',
143 |                 ],
144 |                 'podcast_id' => [
145 |                     'location' => 'uri',
146 |                     'type' => 'string'
147 |                 ],
148 |                 'episode_id' => [
149 |                     'location' => 'query',
150 |                     'type' => 'integer'
151 |                 ],
152 |                 'timeframe' => [
153 |                     'location' => 'query',
154 |                     'type' => 'string', // recent, year, all, custom
155 |                 ],
156 |                 'start_date' => [
157 |                     'location' => 'query',
158 |                     'type' => 'string', // YYYY-MM-DD
159 |                 ],
160 |                 'end_date' => [
161 |                     'location' => 'query',
162 |                     'type' => 'string', // YYYY-MM-DD
163 |                 ],
164 |             ]
165 |         ],
166 |     ],
167 |     'models' => [
168 |         'getResponse' => [
169 |             'type' => 'object',
170 |             'additionalProperties' => [
171 |                 'location' => 'json'
172 |             ]
173 |         ]
174 |     ]
175 | ];
176 | 


--------------------------------------------------------------------------------