2017-07-18 37 views
0

私はGupshupで働いていて、チャットにサブビューを追加したいと思います。 ;Gupshupが作成する投稿を埋め込む埋め込みフォーム

context.simplehttp.makePost(URL、JSON.stringify(パラメータ)、ヘッダ、パーサ):

var url="https://api.gupshup.io/sm/api/facebook/smartmsg/form/create"; 
var header = {"apikey":"xxxxxxxxxxxxxxxxxxx","Content-Type": "application/x-www-form-urlencoded","Accept":"application/json"}; 
var param={"formJSON":{ 
    "title": "This is a test.", 
    "autoClose": false, 
    "message": "Thank You", 
    "callback-url": "https://www.gupshup.io/developer/bot/Cotizador/public", 
    "fields": [{ 
     "type": "fbid", 
     "name": "fbname", 
     "label": "fbName" 
    }, { 
     "type": "input", 
     "name": "name", 
     "label": "Name", 
     "validations": [{ 
      "regex": "^[A-Z a-z]+$", 
      "msg": "Only alphabets are allowed in this field" 
     }, { 
      "regex": "^[A-Z a-z]{6,}$", 
      "msg": "Minimum 6 characters required" 
     }] 
    }, { 
     "type": "radio", 
     "name": "gender", 
     "label": "Gender", 
     "options": [ 
      "Male", 
      "Female" 
     ], 
     "validations": [{ 
      "regex": "", 
      "msg": "" 
     }] 
    }, { 
     "type": "select", 
     "name": "account", 
     "label": "AccountType", 
     "options": [ 
      "current", 
      "savings" 
     ], 
     "validations": [{ 
      "regex": "", 
      "msg": "" 
     }] 
    }, { 
     "type": "checkbox", 
     "name": "interest", 
     "label": "Interests", 
     "options": [ 
      "Cooking", 
      "Reading" 
     ], 
     "validations": [{ 
      "regex": "", 
      "msg": "" 
     }] 
    }], 
    "users": [ 
     "Testing" 
    ] 
}} 

とコールのポストで: が、これはvarsの私が作成し、これを行うには

そして、私のコールバック

function parser(context, event) { 
    context.console.log("Handler https") 
      var result= JSON.parse(event.getresp); 
     if(result=="success"){ 
     context.sendResponse("We have successfully stored your data"); 
     }else{ 
       context.sendResponse("We dont shoot"); 
     } 
} 

しかし、要求のポストを作るが、私のチャットやコールバックでの応答を示しません。何が間違っている?

答えて

2

Gupshupからのソーホンはこちら。あなたが行うとき、このように

[{ 
    "embedlink": "https://api.gupshup.io/sm/api/facebook/smartmsg/embed/66438dde-ec76-4d6e-a0d0-8cfc0c730e57", 
    "expired": false, 
    "fb-button": { 
     "title": "This is a test.", 
     "type": "web_url", 
     "url": "https://api.gupshup.io/sm/api/facebook/smartmsg/embed/66438dde-ec76-4d6e-a0d0-8cfc0c730e57", 
     "webview_height_ratio": "tall" 
    }, 
    "id": "66438dde-ec76-4d6e-a0d0-8cfc0c730e57", 
    "signed-for": { 
     "display": "Testing", 
     "subdisplay": "Testing" 
    }, 
    "smid": "1009" 
}] 

var result= JSON.parse(event.getresp); 
    if(result=="success"){ 

context.sendResponse(結果は)あなたが上記を参照全体JSONが表示されます 使用しているAPIからの結果はこれです。 「期限切れ」フィールドを表示するには、result.expiredを使用します。

詳細については、this documentを確認してください。

関連する問題