From 98264bf4807a1b82ee7d1584ebb73b4bbba58e6e Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Sat, 14 May 2016 12:06:49 +0200 Subject: [PATCH] allow text/plain responses --- examples/gistlog.php | 30 ++++++++++++++++++++++++++++++ lib/API/ContentType.php | 1 + 2 files changed, 31 insertions(+) create mode 100755 examples/gistlog.php diff --git a/examples/gistlog.php b/examples/gistlog.php new file mode 100755 index 0000000..455b30d --- /dev/null +++ b/examples/gistlog.php @@ -0,0 +1,30 @@ +#!/usr/bin/env php + "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(); + } +}); diff --git a/lib/API/ContentType.php b/lib/API/ContentType.php index e8f75dc..b2eb5fb 100644 --- a/lib/API/ContentType.php +++ b/lib/API/ContentType.php @@ -17,6 +17,7 @@ class ContentType "html" => "self::fromData", "diff" => "self::fromData", "patch" => "self::fromData", + "text/plain"=> "self::fromData", ]; private $type; -- 2.30.2