2011-01-25 2 views
0

Попытка отправить данные на сервер, который принимает данные в следующем формате VERIFY_DATA=MER_ID=xxx|MER_TRNX_ID=xxx| MER_TRNX_AMT=xxx Будут ли следующие линии?Отправка данных с помощью curl

$datatopost="VERIFY_DATA=MER_ID=xxx|MER_TRNX_ID=xxx| MER_TRNX_AMT=xxx"; 
curl_setopt ($ch, CURLOPT_POSTFIELDS,$datatopost);<br /> 

Любая помощь будет оценена по достоинству, я новичок в завивке.

ответ

1

Вы можете использовать этот article, чтобы узнать, как это сделать должным образом.

Я лично использовал этот код, чтобы сделать это на проекте шахты

$data="from=$from&to=$to&body=".urlencode($body)."&url=$url"; 
//$urlx contains the url where you want to post. $data contains the data you are posting 
//$resp contains the response. 
     $process = curl_init($urlx); 

     curl_setopt($process, CURLOPT_HEADER, 0); 

     curl_setopt($process, CURLOPT_POSTFIELDS, $data); 

     curl_setopt($process, CURLOPT_POST, 1); 

     curl_setopt($process, CURLOPT_RETURNTRANSFER,1); 

     curl_setopt($process,CURLOPT_CONNECTTIMEOUT,1); 

     $resp = curl_exec($process); 

     curl_close($process); 
0

здесь является рабочим примером в PHP. Это запрашивает и возвращает котировку FX. Мой запрос данных находится в URL-адресе, который находится в почтовых полях, хотя вам нужно настроить. Похоже, что у вас есть пробелы в данных, которые вы передаете «x | ME», я подозреваю, что это не понравится.

$ch = curl_init(); // initialise CURL 
// set URL and other appropriate options 
curl_setopt($ch, CURLOPT_URL, $curl_opt_string); // this contains the URL and the request 
curl_setopt($ch, CURLOPT_HEADER, false); // no header 
curl_setopt($ch, CURLOPT_INTERFACE, "93.129.141.79"); // where to send the data back to/outgoing network 
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); // tell it what the agent is 
curl_setopt($ch, CURLOPT_POST, 1); // want the data back as a post 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return as a string rather than to the screen 
$output = curl_exec($ch); // varu=iable to return it to 

curl_close($ch); // close cURL resource, and free up system resources 

$subject = $output; // get the data 

я построил свои выходные жала следующего

$curl_opt_string = "http://msxml.rexefore.com/index.php?username=MiJoee4r65&password=L8e44Y&instrument=245.20." . $lhsrhs . "LITE&fields=D4,D6"; 
Смежные вопросы