Skip to content

Commit ba10f89

Browse files
committed
readme
1 parent 82e26bf commit ba10f89

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

README.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Google Hangouts Chat
2+
3+
Build the json payload to create or update messages using the Hangout Chat Webhooks
4+
5+
* [Official documentation](https://developers.google.com/hangouts/chat/reference/rest/v1/spaces.messages)
6+
7+
## Objects
8+
9+
* Card
10+
* Header
11+
* Message
12+
* Section
13+
* Widget
14+
* Markup\ActionParameter
15+
* Markup\Button
16+
* Markup\FormAction
17+
* Markup\Icon
18+
* Markup\Image
19+
* Markup\KeyValue
20+
* Markup\OnClick
21+
22+
## Usage
23+
24+
```
25+
<?php
26+
27+
use Dmouse\GoogleBot\Message;
28+
use Dmouse\GoogleBot\Card;
29+
use Dmouse\GoogleBot\Header;
30+
use Dmouse\GoogleBot\Section;
31+
use Dmouse\GoogleBot\Widget;
32+
use Dmouse\GoogleBot\Markup\Image;
33+
use Dmouse\GoogleBot\Markup\OnClick;
34+
use Dmouse\GoogleBot\Markup\FormAction;
35+
use Dmouse\GoogleBot\Markup\ActionParameter;
36+
use Dmouse\GoogleBot\Markup\Button;
37+
use Dmouse\GoogleBot\Markup\Icon;
38+
use Dmouse\GoogleBot\Markup\KeyValue;
39+
40+
require __DIR__ . '/vendor/autoload.php';
41+
42+
$payload = new Message();
43+
44+
$param = ActionParameter::create()
45+
->key('key')
46+
->value('val val')
47+
;
48+
49+
$form = FormAction::create()
50+
->actionMethodName('form name')
51+
->addParameter($param)
52+
;
53+
54+
$onClick = OnClick::create()
55+
->openLink('http://go.com')
56+
->action($form)
57+
;
58+
59+
$i = Image::create()
60+
->imageUrl('http://image.com')
61+
->aspectRatio(100)
62+
->onClick($onClick)
63+
;
64+
65+
$button = Button::create()
66+
->textButton('text button', $onClick)
67+
->imageButton($onClick, 'name image button', Icon::BOOKMARK)
68+
;
69+
70+
$widget_a = Widget::create()
71+
->textParagraph('text widget')
72+
->image($i)
73+
->addButton($button)
74+
->keyValue(KeyValue::create()->topLabel("top label"))
75+
;
76+
77+
$s = Section::create()
78+
->header('yay up1')
79+
->addWidget($widget_a)
80+
;
81+
82+
$payload->text("sample text")
83+
->name("My Name")
84+
->createTime(time())
85+
->previewText("preview text")
86+
->fallbackText("fallback text")
87+
->argumentText("argument text")
88+
->thread("spaces/ABBAob4-eD8/threads/F3ZjK-OTJ3")
89+
90+
->addCard(
91+
Card::create()
92+
->name("yay")
93+
->header(
94+
Header::create()
95+
->title("yay")
96+
->subtitle("Subtitle")
97+
->imageUrl("http://example.com/...")
98+
->imageStyle(Header::IMAGE_STYLE_AVATAR)
99+
)
100+
->addSection($s)
101+
)
102+
;
103+
104+
105+
print_r("" . $payload);
106+
107+
```

0 commit comments

Comments
 (0)