2011-01-25 123 views
0

嘗試將數據發送到接受以下格式的數據的服務器 VERIFY_DATA=MER_ID=xxx|MER_TRNX_ID=xxx| MER_TRNX_AMT=xxx 請問以下行嗎?使用捲曲發送數據

$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工作示例的項目。這要求並返回一個外匯報價。我的數據請求位於您所在域的URL中,但您需要進行調整。它看起來好像你傳遞的數據中有空格「x |我」,我懷疑它不會那樣。

$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";