伊莉討論區
標題:
php 串接LINE notify 的方法
[打印本頁]
作者:
daneil4444
時間:
2018-8-27 10:33 PM
標題:
php 串接LINE notify 的方法
各位大大好
最近要做一個自動推送line訊息給用戶的功能必須串接LINE notify這玩意兒..
查過很多資料幾乎都是取用戶token再用postman程式來送訊息
但是我想用php請問該如何寫呢?
去他們官網看也沒有這方面說明
麻煩各位幫幫忙
作者:
chengpocheng
時間:
2018-8-30 10:57 AM
本帖最後由 chengpocheng 於 2018-8-30 10:58 AM 編輯
可以使用php_curl
就看LINE notify提供的接口是用POST GET PUT...等
舉例來說
$send_url = "http://example.com";
$token_post = array(
"code" => "testCode",
"client_id" => "testClient",
"client_secret" =>”testScecret”,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $send_url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $token_post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1);
$response = curl_exec($ch); // 回傳 access_token
curl_close($ch);
複製代碼
因為我沒看line notify的串接文件,變數token_post裡面的參數要靠你自行去查閱,但根據我的經驗,取得access token的流程差不多就是這樣
作者:
daneil4444
時間:
2018-8-30 02:04 PM
本帖最後由 daneil4444 於 2018-8-30 03:06 PM 編輯
chengpocheng 發表於 2018-8-30 10:57 AM
可以使用php_curl
就看LINE notify提供的接口是用POST GET PUT...等
剛去試成功取得access_token我後來找到參數了,順便貼在下面
$token_post = array(
"grant_type" => "authorization_code",
"redirect_uri" => "******",
"code" => "*****",
"client_id" => "******",
"client_secret" =>"*********",
);
複製代碼
成功推送!@chengpocheng謝拉
作者:
daneil4444
時間:
2018-8-30 02:06 PM
chengpocheng 發表於 2018-8-30 10:57 AM
可以使用php_curl
就看LINE notify提供的接口是用POST GET PUT...等
剛去找參數成功取得access token,順便貼在下面
$token_post = array(
"grant_type" => "authorization_code",
"redirect_uri" => "http://localhost/",
"code" => "***********",
"client_id" => "***************",
"client_secret" =>"**************",
);
已成功推送!@chengpocheng謝嚕
作者:
xiaofu95
時間:
2018-9-12 04:52 PM
提示:
作者被禁止或刪除 內容自動屏蔽
歡迎光臨 伊莉討論區 (http://a405.file-static.com/)
Powered by Discuz!