Skip to content

Instantly share code, notes, and snippets.

@songwutk
Last active May 25, 2020 09:21
Show Gist options
  • Save songwutk/f895bdf91cd49f96437dbe5105901edf to your computer and use it in GitHub Desktop.
Save songwutk/f895bdf91cd49f96437dbe5105901edf to your computer and use it in GitHub Desktop.
Yii2 Guzzle - Linenotify
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