이메일을 수집하기 위해 사용자에게 텍스트 메시지를 보내기 위해 post 매개 변수를 포착하는 vxml 스크립트가 있습니다.json_decode에서 Json 데이터 변수 잡기
다음은 스크립트
<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\"?>\n";
$PIN = $_GET['pin'];
$CALLER = 1 . $_GET['callID'];
$params['to'] = $CALLER;
$params['from'] = "16172075679";
$params['body'] = "Please Respond To This Text Message With Your Email Address So We Can Better Serve You.";
$params['result_url'] = "http://hubenterprises.com.mx/ParseSMSresponse.php";
//initialize curl
$ch = curl_init();
// set necessary curl options
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_URL, "http://hosting.plumgroup.com/ws/sms/queue.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "[email protected]:Huba5474");
$result = curl_exec($ch);
// process the json result body
$json = (json_decode($result, true) !== null) ? json_decode($result, true) : false;
$success = false;
if ($json['status'] == 'success') {
$success = true;
$message_reference = $json['result']['sms_message']['sms_message_id'];//UPLOAD SMS MESSAGE ID
//INSERT HERE
// TODO: insert this value into your database with a pin or what have you for the user
}
curl_close($ch);
?>
<vxml version="2.0">
<form>
<block>
<log><? print_r($params) ?></log>
hello <value expr="'<? echo($CALLER) ?>'"/>
<?
var_dump($json);
var_dump($message_reference);
?>
<return namelist=""/>
</block>
</form>
</vxml>
내가 ($의 JSON)을 위해서 var_dump 때이를 출력하고 문자 메시지가 전송됩니다이다.
<?xml version="1.0"?>
<vxml version="2.0">
<form>
<block>
<log>Array
(
[to] => 18159856396
[from] => 16172075679
[body] => Please Respond To This Text Message With Your Email Address So We Can Better Serve You.
[result_url] => http://hubenterprises.com.mx/ParseSMSresponse.php
)
</log>
hello <value expr="'18159856396'"/>
array(3) {
["status"]=>
string(7) "success"
["error"]=>
string(0) ""
["result"]=>
array(1) {
["sms_messages"]=>
array(1) {
[0]=>
array(7) {
["sms_message_id"]=>
string(32) "5a6c5c7114a74679861209c27a083542"
["to"]=>
string(11) "18159856396"
["from"]=>
string(10) "6172075679"
["body"]=>
string(87) "Please Respond To This Text Message With Your Email Address So We Can Better Serve You."
["result_url"]=>
string(49) "http://hubenterprises.com.mx/ParseSMSresponse.php"
["request_timestamp"]=>
int(1472838803)
["status"]=>
string(6) "queued"
}
}
}
}
NULL
<return namelist=""/>
</block>
</form>
</vxml>
저는 json_decode에 익숙하지 않습니다. 이 정보를 데이터베이스에 업로드 할 수 있도록 변수에서 출력하는 매개 변수를 잡는 방법은 무엇입니까? $ message_reference (var_dump ($ message_reference); null을 반환 할 때)에 잡기를 시도했습니다.
제안 사항?
덕분에, 나는 그것을 하나 개의 응답에 여러 SMS 메시지를 사용하는 경우를 포함하는 실행 – Krunkmaster
업데이트 대답을 줄 수 있습니다. 행운을 빕니다. – Lynne
이 스크립트는 호출 당 텍스트 하나만 보냅니다. 그래서 내가 할 필요가 var에 SMS 메시지 ID를 캡처합니다. 다른 모든 정보는 중요하지 않습니다. – Krunkmaster