开发者

Curl not sending data to link point

Here is the curl code which i had written

$url='url to connect to link point';
     $port  = (port number);
     $fields = array(
        'storename'=>urlencode('storenumber'),
                        'cardnumber'=>urlencode($row['cnumber']),
                     'cmonth'=>urlencode($row['cmonth']),
  'cyear'=>urlencode($row['cyear']),
                     'ctype'=>urlencode($row['ctype']),
                      'securitycode'=>urlencode($row['csecuritycode']),
   'chargetotal'=>urlencode($row['camount']),
       'customer_ip'=>urlencode($_SERVER['REMOTE_ADDR']),
        'submit'=>urlencode('submit'),
        'ponumber'=>urlencode('ponumber'),
        'totalamount'=>urlencode($row['camount']),
        'txntype'=>urlencode('sale'),
        'txnmode'=>urlencode('live'),
        'mode'=>urlencode('payonly'),
        'txnmode'=>urlencode('live'),
        'od'=开发者_开发技巧>urlencode($row['id1']),
      'osCsid'=>urlencode($_GET['osCAdminID'])        
               ); 

     foreach($fields as $key=>$value) 
     {     
      $fields_string .= $key.'='.$value.'&'; 
      }
                     rtrim($fields_string,'&');
     $ch = curl_init();
     curl_setopt($ch,CURLOPT_URL,$url);      
        curl_setopt($ch, CURLOPT_POST, 1);  
     curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
     curl_setopt($ch,CURLOPT_POST,count($fields));    
     curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
     echo $fields_string;


      $result = curl_exec($ch);
      echo"$result";


Try this

$url='url to connect to link point';
$port = (port number); 
$fields = array(
    'storename'=>urlencode('storenumber'),
    'cardnumber'=>urlencode($row['cnumber']),
    'cmonth'=>urlencode($row['cmonth']),
    'cyear'=>urlencode($row['cyear']),
    'ctype'=>urlencode($row['ctype']),
    'securitycode'=>urlencode($row['csecuritycode']),
    'chargetotal'=>urlencode($row['camount']),
    'customer_ip'=>urlencode($_SERVER['REMOTE_ADDR']),
    'submit'=>urlencode('submit'),
    'ponumber'=>urlencode('ponumber'),
    'totalamount'=>urlencode($row['camount']),
    'txntype'=>urlencode('sale'),
    'txnmode'=>urlencode('live'),
    'mode'=>urlencode('payonly'),
    'txnmode'=>urlencode('live'),
    'od'=>urlencode($row['id1']),
    'osCsid'=>urlencode($_GET['osCAdminID'])
 );

//url-ify the data for the POST 
foreach($fields as $key=>$value) { $fields_string []= $key.'='.$value; } 
$fields_string=implode('&',$fields_string);

//open connection 
$ch = curl_init();
//set the url, number of POST vars, POST data 
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
//execute post 
$result = curl_exec($ch);
//close connection 
curl_close($ch);
echo $result;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜