我想编写一个简单的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" );
}
?>