Facebook Gupshup使用post创建嵌入表单

Facebook Gupshup使用post创建嵌入表单,facebook,post,gupshup,Facebook,Post,Gupshup,我与Gupshup合作,我想在聊天中添加子视图。 为此,我创建了以下变量: 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={"fo

我与Gupshup合作,我想在聊天中添加子视图。 为此,我创建了以下变量:

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"
    ]
}}
并致电:

context.simplehttp.makePost(url,JSON.stringify(param),头,解析器)

还有我的回电

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");
       }
}
但在什么时候,发布请求,但不要在聊天或回调中显示响应。我做错了什么?

这里是Gupshup的Sohan。 您使用的API的结果如下:

[{
    "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"){
sendResponse(result)将显示上面看到的整个JSON。要显示“过期”字段,可以使用
result.expired

查看更多信息。

这里是Gupshup的Sohan。 您使用的API的结果如下:

[{
    "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"){
sendResponse(result)将显示上面看到的整个JSON。要显示“过期”字段,可以使用
result.expired

查看更多信息