VOIP API PHP POST到JavaScript

问题描述 投票:0回答:0

我想得到一些帮助,把这段PHP代码翻译成JS。我承认我以前没有用过什么PHP,我不知道这个POST请求是怎么做的。我是否需要使用jQuery或Node.js?谢谢你的时间

<?php

$user = ""; 
$pass= "";
$phone= ""; 
$text = ""; 
$url=urlencode("mywebsite...");

$curl_options = array(
   CURLOPT_URL => "website...",
   CURLOPT_POST => true,
   CURLOPT_POSTFIELDS => "user=$user&pass=$pass&phone=$phone&text=$text&url=$url",
   CURLOPT_RETURNTRANSFER => true,
   CURLOPT_HEADER => false,
   CURLOPT_TIMEOUT => 30,
   CURLOPT_CONNECTTIMEOUT => 5
);

$curl = curl_init();
curl_setopt_array( $curl, $curl_options );
$result = curl_exec( $curl );

$response = new SimpleXMLElement($result);
$send_reponse=$response->result;

if ($send_reponse=='failed'){//eroare
   echo "error: ".$response->description;
}else{   echo "message sent=".$response->description;
}

?>
javascript php voip
© www.soinside.com 2019 - 2024. All rights reserved.