通过PHP在另一个网站上发送数据

时间:2013-10-24 17:11:36

标签: php

所以我甚至不知道这是否可能,但基本上我想为一个客户创建一个后台办公室,以便在两个市场(play.com和亚马逊)上处理他的销售。

我能用PHP填写表单并发送数据吗?我是否能够登录网站以获取日期(新订单等)

我在那里找到了部分答案: Creating a 'robot' to fill form with some pages in

我怀疑PHP不是这种语言,任何建议都将不胜感激!

5 个答案:

答案 0 :(得分:2)

答案的另一部分就在这里。您可以使用 cURL 来实现此目标。

使用 cURL ,您可以登录网站。这里的示例示例为您提供了一个启动。

<?php
$username="name@mail.com"; 
$password="mypassword"; 
$url="http://www.myremotesite.com/login.php"; 

$postdata = "email=".$username."&password=".$password; 

$ch = curl_init(); 
curl_setopt ($ch, CURLOPT_URL, $url); 
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 
curl_setopt ($ch, CURLOPT_TIMEOUT, 60); 
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt ($ch, CURLOPT_REFERER, $url); 
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); 
curl_setopt ($ch, CURLOPT_POST, 1); 
$result = curl_exec ($ch); 

echo $result;  
curl_close($ch);

答案 1 :(得分:0)

您可以尝试SimpleTest,但通常 big 服务提供了一个API接口来与它们进行交互。

答案 2 :(得分:0)

$q="INSERT INTO `table`(`fname`, `lname`, `phone`, `zipcode`, `status`, `pregnant`, `month`, `day`, `year`, `ft`, `inch`, `lb`, `people`, `email`, `annual`, `recent`, `address`, `city`, `state`, `quotetype`, `unsubscribe`, `unsubscribe_type`) VALUES (
    '".$_POST['fname']."',
    '".$_POST['lname']."',
    '".$_POST['ph']."',
    '".$_POST['zip']."',
        'Accept',
    '".$_POST['gender']."',
    '".$_POST['mm']."',
    '".$_POST['dd']."',
    '".$_POST['yyyy']."',
    '5','8','80',
    '".$_POST['kids']."',
    '".$_POST['email']."',
    '".$_POST['income']."',
    '".$_POST['type']."',
    '".$_POST['address']."',
    '".$_POST['city']."',
    '".$_POST['state']."',
    'Lead','0','no')";
    $sql=mysql_query($q);
    if($sql)
    {echo "Lead Successfully submitted";}
    else
    {echo "Not Done";} 
    //Recive Data page like : get-data.php

答案 3 :(得分:0)

$ handle = curl_init();

$ url =“ http://example.com/test.php”;

//具有字段名称和值的数组。

$ postData = array(

'名字'=>'',

'lastName'=>'Gaga',

'提交'=>'确定' );

curl_setopt_array($ handle,

array( CURLOPT_URL => $ url,

 // Enable the post response.

CURLOPT_POST       => true,

// The data to transfer with the response.

CURLOPT_POSTFIELDS => $postData,

CURLOPT_RETURNTRANSFER     => true, ));

$ data = curl_exec($ handle);

curl_close($ handle);

echo $ data;

答案 4 :(得分:-1)

$url="https://example.com/add_lead.php"; 

$postdata = "fname=".$fname."&lname=".$lname."&mm=".$mm."&dd=".$dd."&yyyy=".$yyyy."&email=".$email."&city=".$city."&state=".$state."&zip=".$zip."&address=".$address."&gender=".$lname."&ph=".$ph."&income=".$income."&type=".$type."&kids=".$kids; 

$ch = curl_init(); 
curl_setopt ($ch, CURLOPT_URL, $url); 
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 
curl_setopt ($ch, CURLOPT_TIMEOUT, 60); 
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt ($ch, CURLOPT_REFERER, $url); 
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); 
curl_setopt ($ch, CURLOPT_POST, 1); 
$result = curl_exec ($ch); 

echo $result;  
curl_close($ch);

//发送请求参数页面,如send-data.php