如何发送帖子到班级形式的URL?

时间:2019-12-26 14:17:24

标签: php web-services

我想编写一个简单的PHP代码,该代码会将数据发送到URL中的类。 我已经编写了代码,但这仅用于直接将数据发送到URL。 怎么写这段代码? 类名是“ sendmsg”。

<?php

$url = 'https://thxmain.cellmobilen.net:443/Charg/service/ChargingMobile';

$data = array(
 'username' => '?',
 'password' => '?',
 'domain' => '?',
 'channel' => '?',
 'mobilenum' => '?',
 'serviceId' => '?',
 'price' => '?',
 'trackingId' => '?'
);

$options = array(
   'http' => array(
       'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
       'method'  => 'POST',
       'content' => http_build_query($data)
   )
);

$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);

if ($result !== FALSE) {
 var_dump($result);
}else{
 print( "Code is wrong" );
}

?>


0 个答案:

没有答案