1

I have PHP code like below and I want to write a function which makes the same job in C#. However, I didn't understand what curl_setotp does, exactly. How can I write a function like that?

public static function sendDataAuth( $url, $doc,$authData) {
        
    $ch = curl_init($url );
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $doc);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    
    curl_setopt($ch,CURLOPT_HTTPHEADER,array('OpenPayu-Signature:'.$authData));
            
    $response = curl_exec($ch);
    
    return $response;
}
5
  • it simply changes some settings inside curl, e.g. curl defaults to GET requests, so curlopt_post=>true changes it to use a POST instead. Commented Oct 8, 2012 at 4:58
  • In fact, curl_setopt($ch, CURLOPT_POSTFIELDS, $doc) and curl_setopt($ch,CURLOPT_HTTPHEADER,array('OpenPayu-Signature:'.$authData)); make me confused. Can you explain theese? Commented Oct 8, 2012 at 5:24
  • php.net/curl_setopt just read the docs. all the options are listed there Commented Oct 8, 2012 at 5:26
  • 1
    @mavera CURLOPT_HTTPHEADER is just a header to send and CURLOPT_POSTFIELDS is data to send. Commented Oct 8, 2012 at 5:27
  • @loler Thanks for your help. Move this comment to your answer. Then I'll check it accepted. Commented Oct 8, 2012 at 5:33

1 Answer 1

2

curl_setopt sets some options for cURL. You can see what these options mean on php.net.

CURLOPT_HTTPHEADER is just a header to send and CURLOPT_POSTFIELDS is data to send.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.