allow text/plain responses
authorMichael Wallner <mike@php.net>
Sat, 14 May 2016 10:06:49 +0000 (12:06 +0200)
committerMichael Wallner <mike@php.net>
Sat, 14 May 2016 10:06:49 +0000 (12:06 +0200)
examples/gistlog.php [new file with mode: 0755]
lib/API/ContentType.php

diff --git a/examples/gistlog.php b/examples/gistlog.php
new file mode 100755 (executable)
index 0000000..455b30d
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/env php
+<?php
+
+require __DIR__."/../vendor/autoload.php";
+
+$api = new seekat\API([
+       "Authentication" => "token ".getenv("GUTHUB_TOKEN")
+]);
+
+$api(function($api) {
+       $gists = yield $api->users->m6w6->gists();
+       while ($gists) {
+               foreach ($gists as $gist) {
+                       foreach ($gist->files as $name => $file) {
+                               if ($name == "blog.md") {
+                                       $text = $file->as("raw")->raw();;
+                                       $head = $gist->description." ".$gist->created_at;
+                                       echo "$head\n";
+                                       echo str_repeat("=", strlen($head))."\n\n";
+                                       echo trim(yield $text);
+                                       echo "\n\nThis was my last gistlog, pipe it through \$PAGER if ";
+                                       echo "you really want to read it or visit https://gistlog.co/m6w6\n";
+                                       return;
+                               }
+                       }
+               }
+
+               $gists = yield $gists->next();
+       }
+});
index e8f75dca1abbc03f343f1d507691fb34c67aef3e..b2eb5fbc0690f74af90b67214d37a6ca93b452a1 100644 (file)
@@ -17,6 +17,7 @@ class ContentType
                "html"          => "self::fromData",
                "diff"          => "self::fromData",
                "patch"         => "self::fromData",
                "html"          => "self::fromData",
                "diff"          => "self::fromData",
                "patch"         => "self::fromData",
+               "text/plain"=> "self::fromData",
        ];
 
        private $type;
        ];
 
        private $type;