将数据从一个站点发布到另一个站点

时间:2014-04-16 11:52:02

标签: php post soap

<?php
function get_url($url, $timeout = 10) {

foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');
class Post {
var $updateUrl = 'http://api.logicmelon.com/AddAdvert';


$url = $file_name;
$fields = array(
            '__VIEWSTATE'=>urlencode($state),
            '__EVENTVALIDATION'=>urlencode($valid),
            'btnSubmit'=>urlencode('Submit')
        );
$ch = curl_init();

      curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1");
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch,CURLOPT_POST,count($fields));
      curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
      curl_setopt($ch, CURLOPT_ENCODING, "");
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_AUTOREFERER, true);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);    # required for https urls
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
      curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
      curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
      $response = curl_getinfo($ch);
      curl_close($ch);


$result = curl_exec($ch);
print $result;
}
}
?>

我正在尝试发布数据,但我不确定这是如何工作的,有些人可以帮助我,以便我可以将数据从我的文本字段发送到他们的网站,以便它提交我给出的详细信息

2 个答案:

答案 0 :(得分:0)

在此链接中,您可能会得到解决方案,几乎相同的问题。

Check here.

答案 1 :(得分:0)

HERE是使用远程服务器上的curl执行HTTP POST的优秀教程