From 8ba2200a8db99d91cb6a8e3937f967a4929a6d0e Mon Sep 17 00:00:00 2001 From: Grummfy Date: Tue, 7 Oct 2014 23:26:41 +0200 Subject: [PATCH 1/2] * add documentation * fix phpdoc --- README.md | 7 ++++++- doc/README.md | 2 ++ doc/TOKEN.md | 8 ++++++++ src/Contracts/Http/Response.php | 2 +- src/Http/SlackResponse.php | 2 +- 5 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 doc/README.md create mode 100644 doc/TOKEN.md diff --git a/README.md b/README.md index 4d86104..355a6fa 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,9 @@ Here is a very simple example of using this package: ```php execute('chat.postMessage', [ 'text' => 'Hello, world!' ]); -if ($response['ok']) +$responseBody = $response->getBody(); + +if ($responseBody && responseBody['ok']) { // Command worked } diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 0000000..74fe4a3 --- /dev/null +++ b/doc/README.md @@ -0,0 +1,2 @@ +* TOKEN.md Get the token for communication with API of slack + diff --git a/doc/TOKEN.md b/doc/TOKEN.md new file mode 100644 index 0000000..13560ca --- /dev/null +++ b/doc/TOKEN.md @@ -0,0 +1,8 @@ +To communicate through the API of Slack, you need a token. Here is the way to get it. + +1. Go to https://api.slack.com/ +2. In "Authentication" section, click on generate token. +3. This is your token, change in sample 'xoxp-some-token-for-slack' by the one you just receive. + + + diff --git a/src/Contracts/Http/Response.php b/src/Contracts/Http/Response.php index b495f32..c87893e 100644 --- a/src/Contracts/Http/Response.php +++ b/src/Contracts/Http/Response.php @@ -5,7 +5,7 @@ interface Response { /** * Gets the body of the response. * - * @return string + * @return array */ public function getBody(); diff --git a/src/Http/SlackResponse.php b/src/Http/SlackResponse.php index dccfdfb..34e6939 100644 --- a/src/Http/SlackResponse.php +++ b/src/Http/SlackResponse.php @@ -5,7 +5,7 @@ class SlackResponse implements \Frlnc\Slack\Contracts\Http\Response, \JsonSerial /** * The response body. * - * @var string + * @var array */ protected $body; From b8b12ca63388d90a16151980316ffd0c5bfd639b Mon Sep 17 00:00:00 2001 From: Grummfy Date: Tue, 7 Oct 2014 23:28:31 +0200 Subject: [PATCH 2/2] link to doc --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 355a6fa..5737a26 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ use Frlnc\Slack\Core\Commander; $interactor = new CurlInteractor; $interactor->setResponseFactory(new SlackResponseFactory); +// see doc/Toekn.md for more informations $commander = new Commander('xoxp-some-token-for-slack', $interactor); $response = $commander->execute('chat.postMessage', [