0

parse.com でアプリを開発しました

plivo を使用して SMS を送信する次の関数を作成しました。

function sendRSVPSMS(PlivoNumber, GuestNumber, Message) {
    var payLoad = {
        src: PlivoNumber,
        dst: GuestNumber,
        text: Message
    };
    Parse.Cloud.httpRequest({
        url: "<My Plivo URL>",
        method: "POST",
        body: payLoad,
        success: function (httpResponse) {
            console.log('httpRequest success');
            response.success("Sent successfully");
        },
        error: function (httpResponse) {
            console.log('SendSMS: Request failed');
            response.error('Request failed');
        }
    });
}

その理由は何ですか?

4

2 に答える 2

3

Plivo セールス エンジニアです。

パヴァンは正しいです。本文の JSON 文字列を作成するには、Parse とContent-Type同様にヘッダーを指定する必要があります。application/json

        headers: {
            "Content-Type": "application/json"
        },

またconsole.log(httpResponse)、何か間違ったことを行っているか (間違ったデータを送信しているか、正しく認証していないか)、または何か正しいことを行っているかどうかを通知する必要があります (別名、Plivo API 応答)。どちらの方法でも、 Plivo アカウント ダッシュボードのデバッグ ログを調べて、何を変更する必要があるかを判断api_idするために使用できる情報が表示されます。また、次のような URL を作成して、特定のデバッグ ログに直接移動することもできます。api_idhttps://manage.plivo.com/logs/debug/api/e58b26e5-3db5-11e6-a069-22000afa135b/e58b26e5-3db5-11e6-a069-22000afa135bapi_idParse.Cloud.httpRequest

于 2016-06-30T04:20:13.077 に答える
1

コンテンツ タイプのヘッダーを指定するのを忘れた可能性があります。

"コンテンツタイプ": "アプリケーション/json"

したがって、コードは次のようになります

function sendRSVPSMS(PlivoNumber, GuestNumber, Message) {
    var payLoad = {
        src: PlivoNumber,
        dst: GuestNumber,
        text: Message
    };
    Parse.Cloud.httpRequest({
        url: "<My Plivo URL>",
        method: "POST",
        body: payLoad,
            headers: {
                "Content-Type": "application/json"
            },
        success: function (httpResponse) {
            console.log('httpRequest success');
            response.success("Sent successfully");
        },
        error: function (httpResponse) {
            console.log('SendSMS: Request failed');
            response.error('Request failed');
        }
    });
} 
于 2016-06-29T15:45:52.277 に答える