I want to convert this php curl into asp.net . I am a beginner in asp.net , can someone here help me to convert this curl into asp.net. please .
$handle = curl_init();
if ($this->accessToken) {
$url .= '?access_token=' . $this->accessToken;
} else if ($this->token) {
$url .= '?auth_token=' . $this->token;
} else {
curl_setopt($handle, CURLOPT_USERPWD, $this->username . ':' . $this->password);
}
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, strtoupper($method));
curl_setopt($handle, CURLOPT_HTTPHEADER, array(
'Content-type: multipart/form-data;',
));
if (! empty($options)) {
$files = array();
foreach ($options as $key => $value) {
if (! empty($value) && ! is_array($value) && $value[0] === '@') {
$files[$key] = $this->toCurlFile($value);
unset($options[$key]);
}
}
$data = $files;
if (! empty($options)) {
$data = array_merge($data, array(
'data' => json_encode($options),
));
}
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
}
$response = curl_exec($handle);
What I have tried:
I have tried to convert this using httpwebrequest in asp.net . but given below line of php confusing me. that is the reason , I am not able to start this work to convert it in asp.net.
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, strtoupper($method));
curl_setopt($handle, CURLOPT_HTTPHEADER, array(
'Content-type: multipart/form-data;',