I need to write the below php code in in vb.net .Can somebody help me?
Is there any code converter from php to vb.net?
<?php
function get_token($userName, $userPassword) {
$Url = "http://api.abcdtesting.net/json/token";
$authString = base64_encode($userName . ":" . $userPassword);
$header = array();
$header[] = 'Content-length: 0';
$header[] = 'Content-type: application/json';
$header[] = 'Authorization:' . $authString;
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
if (curl_errno($ch)) {
echo 'error:' . curl_error($ch) . '<br/>';
curl_close($ch);
return '';
} else {
$tk = json_decode($data, true);
curl_close($ch);
return $tk[0]['token'];
}
}
What I have tried:
I need to write the below php code in in vb.net .Can somebody help me?
Is there any code converter from php to vb.net?
<pre><?php
function get_token($userName, $userPassword) {
$Url = "http://api.abcdtesting.net/json/token";
$authString = base64_encode($userName . ":" . $userPassword);
$header = array();
$header[] = 'Content-length: 0';
$header[] = 'Content-type: application/json';
$header[] = 'Authorization:' . $authString;
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
if (curl_errno($ch)) {
echo 'error:' . curl_error($ch) . '<br/>';
curl_close($ch);
return '';
} else {
$tk = json_decode($data, true);
curl_close($ch);
return $tk[0]['token'];
}
}