查看完整版本: php 串接LINE notify 的方法
頁: [1]

daneil4444 發表於 2018-8-27 10:33 PM

php 串接LINE notify 的方法

各位大大好
最近要做一個自動推送line訊息給用戶的功能必須串接LINE notify這玩意兒..
查過很多資料幾乎都是取用戶token再用postman程式來送訊息
但是我想用php請問該如何寫呢?
去他們官網看也沒有這方面說明
麻煩各位幫幫忙<div></div>

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的流程差不多就是這樣...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div>

daneil4444 發表於 2018-8-30 02:04 PM

本帖最後由 daneil4444 於 2018-8-30 03:06 PM 編輯

chengpocheng 發表於 2018-8-30 10:57 AM static/image/common/back.gif
可以使用php_curl
就看LINE notify提供的接口是用POST GET PUT...等


剛去試成功取得access_token我後來找到參數了,順便貼在下面$token_post = array(
    "grant_type" => "authorization_code",
    "redirect_uri" =>...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div>

daneil4444 發表於 2018-8-30 02:06 PM

chengpocheng 發表於 2018-8-30 10:57 AM static/image/common/back.gif
可以使用php_curl
就看LINE notify提供的接口是用POST GET PUT...等



剛去找參數成功取得access token,順便貼在下面
$token_post = array(
    "grant_type" => "authorization_code",
    "redirect_uri" => "http://localhost/",       
    "code" => "***********",
    "client_id" =>...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div>

xiaofu95 發表於 2018-9-12 04:52 PM

不錯哦!謝謝各位的分享++<br><br><br><br><br><div></div>
頁: [1]