Last active
May 25, 2020 09:21
-
-
Save songwutk/f895bdf91cd49f96437dbe5105901edf to your computer and use it in GitHub Desktop.
Yii2 Guzzle - Linenotify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function actionNotify() | |
{ | |
/* command line ====================================== | |
curl -i -X POST -H "Authorization: Bearer b8Gx9LQhQuiJmmuEWkteTPJe93J2jKjFkpr5B2tORmu" -d "message=ทดสอบข้อความจาก cURL" https://notify-api.line.me/api/notify | |
*/ | |
$token='3wKyKg8BpNHCUp3BJw6ovuQWJURJFbVxwFHDYtnWQ5N'; | |
$imgurl='https://forum.yiiframework.com/uploads/default/original/3X/a/1/a1b88caf35558ce965b3ab69c58577408922641a.png'; | |
$msg = 'ทดสอบการส่งข้อความจาก Yii Framework, Guzzle'; | |
// https://devdocs.line.me/files/sticker_list.pdf ตารางสติ๊กเกอร์ | |
$stickerPackageId='1'; | |
$stickerId='106'; | |
$headers = ['headers' => ['Authorization' => 'Bearer '.$token]]; | |
$headers['multipart'] = [ | |
[ | |
'name' => 'message', | |
'contents' => $msg, | |
],[ | |
'name' => 'imageFullsize', | |
'contents' => $imgurl, | |
],[ | |
'name' => 'imageThumbnail', | |
'contents' => $imgurl, | |
],[ | |
'name' => 'stickerPackageId', | |
'contents' => $stickerPackageId, | |
],[ | |
'name' => 'stickerId', | |
'contents' => $stickerId, | |
] | |
]; | |
$client = new \GuzzleHttp\Client(); | |
$res = $client->request('POST', 'https://notify-api.line.me/api/notify', $headers); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment