2017-04-13 157 views
0

當我把這個json數據與PHP curl發送到Facebook Messenger Bot api時,它工作正常。facebook messenger api,模板不起作用

$ jsonData = '{ 「收件人」:{ 「ID」:「' $發送者。 ' 」 }, 「消息」:{ 「文」:「'。$ OBJ'」 } }';

但是,當我使用FB頁面的模板。模板不起作用

$jsonData = '{ 
    "recipient":{ 
    "id":"'.$sender.'" 
    }, 
    "message":{ 
    "attachment":{ 
     "type":"template", 
     "payload":{ 
     "template_type":"generic", 
     "elements":[ 
      { 
      "title":"Hello", 
      "image_url":"http://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/sign-check-icon.png", 
      "subtitle":"Title", 
      "default_action": { 
       "type": "web_url", 
       "url": "https://google.com", 
       "messenger_extensions": true, 
       "webview_height_ratio": "tall", 
       "fallback_url": "https://google.com/" 
      }, 
      "buttons":[ 
       { 
       "type":"web_url", 
       "url":"https://google.com", 
       "title":"View Website" 
       },{ 
       "type":"postback", 
       "title":"Start Chatting", 
       "payload":"DEVELOPER_DEFINED_PAYLOAD" 
       }    
      ]  
      } 
     ] 
     } 
    } 
    } 
}'; 

我想編碼爲Json,替換按鈕,沒有任何反應。 Facebook模板在Messenger更新後不起作用,或者我需要使用新參數?

回答

0

確保:

1:google.com是在你的白名單。
2:它的HTTPS而不是HTTP

,否則你會得到錯誤這樣

{"error":{"message":"(#100) The URL provided is not whitelisted for messenger extensions","type":"OAuthException","code":100,"error_subcode":2018062,"fbtrace_id":"GNd1AXlQsjz"}} 

而且我想,如果你刪除default_aciton將工作:)