将代码PHP转换为C#windows forme应用程序 [英] Convert code PHP to C# windows forme application

查看:65
本文介绍了将代码PHP转换为C#windows forme应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我是C#转换器的PHP代码可以有人这样做吗?



< ;中心],[ 
< form method =post>
< br />
< textarea id =urlname =url_formcols =40rows =8style =width:400px>
< / textarea>
< br />
< input type =submitstyle =margin-top:5px; font-size:18pxvalue =Check/>
< / form>
< / center>

<?php

if($ _ REQUEST ['url_form']){
$ urls = trim($ _ POST ['url_form']);
$ urls = explode(\ n,$ urls);
$ urls = array_filter($ urls,'trim');
}

if(!$ urls){
退出;
}

?>

< div style =margin:auto; width:50%; min-width:400px>
< table width =500cellpadding =5cellspacing =5>
< thead style =text-align:left>
< tr>
< th> ID< / th>
< th>网址< / th>
< th> DA< / th>
< th> PA< / th>
< th> MR< / th>
< th> EL< / th>
< / tr>
< / thead>
< tbody>

<?php

$ check_count = 0;
$ urls_metrics = array();

$ chunked_verified_urls = array_chunk($ urls,80);

foreach($ chunked_verified_urls as $ chunk_section){

sleep(2);
未设置($ url);
$ url = $ chunk_section;

$ seomoz_metrics = getSeomozMetrics($ url);

if($ seomoz_metrics ['error']!=''){
echo错误[SEOMoz]:。$ seomoz_metrics ['error']。< br> ;
} else {
foreach($ seomoz_metrics as $ index => $ seomoz_metric){

$ url_metrics ['pa'] = number_format($ seomoz_metric ['pa'] ,0,'。','');
$ url_metrics ['url'] = $ seomoz_metric ['url'];
$ url_metrics ['da'] = number_format($ seomoz_metric ['da'],0,'。','');
$ url_metrics ['title'] = $ seomoz_metric ['title'];
$ url_metrics ['external_links'] = $ seomoz_metric ['external_links'];
$ url_metrics ['mozrank'] = number_format($ seomoz_metric ['mozrank'],2,'。','');
$ check_count;

echo< tr>< td>;
echo $ check_count;
echo< / td>< td>;
echo str_replace(http://,,$ url_metrics ['url']);
echo< / td>< td>;
echo $ url_metrics ['da'];
echo< / td>< td>;
echo $ url_metrics ['pa'];
echo< / td>< td>;
echo $ url_metrics ['mozrank'];
echo< / td>< td>;
echo $ url_metrics ['external_links'];
echo< / td>;
echo< / tr>;

$ urls_metrics [] = $ url_metrics;
}
}
}
?>

< / tbody>< / table>

< / div>

<?php

函数getSeomozMetrics($ objectURL){

$ accessID =accessID;

$ secretKey =secretKey;

$ expires = time()600;

$ stringToSign = $ accessID。\ n。$ expires;

$ binarySignature = hash_hmac('sha1',$ stringToSign,$ secretKey,true);

$ urlSafeSignature = urlencode(base64_encode($ binarySignature));

$ cols = 68719476736 34359738368 536870912 32768 16384 2048 32 4;

$ requestUrl =http://lsapi.seomoz.com/linkscape/url-metrics/?Cols=\".$cols.\"&AccessID=\".$accessID.\"&Expires =。$到期。 &安培;签名= $ urlSafeSignature。

$ batchedDomains = $ objectURL;
$ encodedDomains = json_encode($ batchedDomains);

$ options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $ encodedDomains
);

$ ch = curl_init($ requestUrl);
curl_setopt_array($ ch,$ options);
$ content = curl_exec($ ch);
curl_close($ ch);

$ response = json_decode($ content,true);

$ count = 0;

if(isset($ response ['error_message'])){
$ metric_list = array('error'=> $ response ['error_message']);
} else {

foreach($ response as $ site_metric){

$ metric_list [$ count] ['url'] = $ objectURL [$ count] ;
$ metric_list [$ count] ['subdomain'] = $ site_metric ['ufq'];
$ metric_list [$ count] ['domain'] = $ site_metric ['upl'];
$ metric_list [$ count] ['pa'] = $ site_metric ['upa'];
$ metric_list [$ count] ['da'] = $ site_metric ['pda'];
$ metric_list [$ count] ['mozrank'] = $ site_metric ['umrp'];
$ metric_list [$ count] ['title'] = $ site_metric ['ut'];
$ metric_list [$ count] ['external_links'] = $ site_metric ['ueid'];
$ count;
}
}
返回$ metric_list;
}

?>





我的尝试:



你好

我是C#转换器的PHP代码可以有人这样做吗?



< center> 
< form method =post>
< br />
< textarea id =urlname =url_formcols =40rows =8style =width:400px>
< / textarea>
< br />
< input type =submitstyle =margin-top:5px; font-size:18pxvalue =Check/>
< / form>
< / center>

<?php

if($ _ REQUEST ['url_form']){
$ urls = trim($ _ POST ['url_form']);
$ urls = explode(\ n,$ urls);
$ urls = array_filter($ urls,'trim');
}

if(!$ urls){
退出;
}

?>

< div style =margin:auto; width:50%; min-width:400px>
< table width =500cellpadding =5cellspacing =5>
< thead style =text-align:left>
< tr>
< th> ID< / th>
< th>网址< / th>
< th> DA< / th>
< th> PA< / th>
< th> MR< / th>
< th> EL< / th>
< / tr>
< / thead>
< tbody>

<?php

$ check_count = 0;
$ urls_metrics = array();

$ chunked_verified_urls = array_chunk($ urls,80);

foreach($ chunked_verified_urls as $ chunk_section){

sleep(2);
未设置($ url);
$ url = $ chunk_section;

$ seomoz_metrics = getSeomozMetrics($ url);

if($ seomoz_metrics ['error']!=''){
echo错误[SEOMoz]:。$ seomoz_metrics ['error']。< br> ;
} else {
foreach($ seomoz_metrics as $ index => $ seomoz_metric){

$ url_metrics ['pa'] = number_format($ seomoz_metric ['pa'] ,0,'。','');
$ url_metrics ['url'] = $ seomoz_metric ['url'];
$ url_metrics ['da'] = number_format($ seomoz_metric ['da'],0,'。','');
$ url_metrics ['title'] = $ seomoz_metric ['title'];
$ url_metrics ['external_links'] = $ seomoz_metric ['external_links'];
$ url_metrics ['mozrank'] = number_format($ seomoz_metric ['mozrank'],2,'。','');
$ check_count;

echo< tr>< td>;
echo $ check_count;
echo< / td>< td>;
echo str_replace(http://,,$ url_metrics ['url']);
echo< / td>< td>;
echo $ url_metrics ['da'];
echo< / td>< td>;
echo $ url_metrics ['pa'];
echo< / td>< td>;
echo $ url_metrics ['mozrank'];
echo< / td>< td>;
echo $ url_metrics ['external_links'];
echo< / td>;
echo< / tr>;

$ urls_metrics [] = $ url_metrics;
}
}
}
?>

< / tbody>< / table>

< / div>

<?php

函数getSeomozMetrics($ objectURL){

$ accessID =accessID;

$ secretKey =secretKey;

$ expires = time()600;

$ stringToSign = $ accessID。\ n。$ expires;

$ binarySignature = hash_hmac('sha1',$ stringToSign,$ secretKey,true);

$ urlSafeSignature = urlencode(base64_encode($ binarySignature));

$ cols = 68719476736 34359738368 536870912 32768 16384 2048 32 4;

$ requestUrl =http://lsapi.seomoz.com/linkscape/url-metrics/?Cols=\".$cols.\"&AccessID=\".$accessID.\"&Expires =。$到期。 &安培;签名= $ urlSafeSignature。

$ batchedDomains = $ objectURL;
$ encodedDomains = json_encode($ batchedDomains);

$ options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $ encodedDomains
);

$ ch = curl_init($ requestUrl);
curl_setopt_array($ ch,$ options);
$ content = curl_exec($ ch);
curl_close($ ch);

$ response = json_decode($ content,true);

$ count = 0;

if(isset($ response ['error_message'])){
$ metric_list = array('error'=> $ response ['error_message']);
} else {

foreach($ response as $ site_metric){

$ metric_list [$ count] ['url'] = $ objectURL [$ count] ;
$ metric_list [$ count] ['subdomain'] = $ site_metric ['ufq'];
$ metric_list [$ count] ['domain'] = $ site_metric ['upl'];
$ metric_list [$ count] ['pa'] = $ site_metric ['upa'];
$ metric_list [$ count] ['da'] = $ site_metric ['pda'];
$ metric_list [$ count] ['mozrank'] = $ site_metric ['umrp'];
$ metric_list [$ count] ['title'] = $ site_metric ['ut'];
$ metric_list [$ count] ['external_links'] = $ site_metric ['ueid'];
$ count;
}
}
返回$ metric_list;
}

?>

解决方案

_REQUEST ['url_form']){/ / blockquote>

urls = trim(


_POST ['url_form']);


Hello
I'm a PHP code to C # Converter can someone do that?

<center>
<form method="post"> 
<br />
<textarea id="url" name="url_form" cols="40" rows="8" style="width: 400px">
</textarea >
<br />
<input type="submit" style="margin-top: 5px; font-size: 18px" value="Check" />
</form>
</center>

<?php

if($_REQUEST['url_form']) {
$urls = trim($_POST['url_form']);
$urls = explode("\n", $urls);
$urls = array_filter($urls, 'trim');
}

if(!$urls) {
	exit;
}

?>

<div style="margin: auto; width: 50%; min-width: 400px">
<table width="500" cellpadding="5" cellspacing="5">
    <thead style="text-align: left">
        <tr>
            <th>ID</th>
            <th>URL</th>
            <th>DA</th>
            <th>PA</th>
            <th>MR</th>
            <th>EL</th>
        </tr>
    </thead>
    <tbody>

<?php

$check_count = 0;
$urls_metrics = array();

$chunked_verified_urls = array_chunk($urls,80);

foreach($chunked_verified_urls as $chunk_section) {
	
	sleep(2);
	unset($url);
	$url = $chunk_section;

	$seomoz_metrics = getSeomozMetrics($url);
	
	if($seomoz_metrics['error'] != '') {
		echo "Error[SEOMoz]: ".$seomoz_metrics['error']."<br>";
	} else {
		foreach($seomoz_metrics as $index => $seomoz_metric) {
			
			$url_metrics['pa'] = number_format($seomoz_metric['pa'], 0, '.', '');
			$url_metrics['url'] = $seomoz_metric['url'];
			$url_metrics['da'] = number_format($seomoz_metric['da'], 0, '.', '');
			$url_metrics['title'] = $seomoz_metric['title'];
			$url_metrics['external_links'] = $seomoz_metric['external_links'];
			$url_metrics['mozrank'] = number_format($seomoz_metric['mozrank'], 2, '.', '');
			$check_count  ;
			
			echo "<tr><td>";
				echo $check_count;
			echo "</td><td>";
				echo str_replace("http://","",$url_metrics['url']);
			echo "</td><td>";
				echo $url_metrics['da'];
			echo "</td><td>";
				echo $url_metrics['pa'];
			echo "</td><td>";
				echo $url_metrics['mozrank'];
			echo "</td><td>";
				echo $url_metrics['external_links'];
			echo "</td>";
			echo "</tr>";

			$urls_metrics[] = $url_metrics;
        }
	}
}
?>

</tbody></table>

</div>

<?php

function getSeomozMetrics($objectURL) {
		
		$accessID = "accessID";
		
		$secretKey = "secretKey";
	
		$expires = time()   600;

		$stringToSign = $accessID."\n".$expires;
		 
		$binarySignature = hash_hmac('sha1', $stringToSign, $secretKey, true);
		
		$urlSafeSignature = urlencode(base64_encode($binarySignature));	 
	
		$cols = 68719476736 34359738368 536870912 32768 16384 2048 32 4;
		 
		$requestUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
		 
		$batchedDomains = $objectURL;
		$encodedDomains = json_encode($batchedDomains);
	
		$options = array(
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_POSTFIELDS     => $encodedDomains
			);
		 
		$ch = curl_init($requestUrl);
		curl_setopt_array($ch, $options);
		$content = curl_exec($ch);
		curl_close( $ch );
		 
		$response = json_decode($content,true);
		
		$count = 0;

    if (isset($response['error_message'])) {
        $metric_list = array('error'=>$response['error_message']);
    } else {
	
        foreach($response as $site_metric) {
			
			$metric_list[$count]['url'] = $objectURL[$count];
			$metric_list[$count]['subdomain'] = $site_metric['ufq'];
           $metric_list[$count]['domain'] = $site_metric['upl'];
           $metric_list[$count]['pa'] = $site_metric['upa'];
           $metric_list[$count]['da'] = $site_metric['pda'];
           $metric_list[$count]['mozrank'] = $site_metric['umrp'];
           $metric_list[$count]['title'] = $site_metric['ut'];
           $metric_list[$count]['external_links'] = $site_metric['ueid'];
			$count  ;  
        }
    }
	return $metric_list;	
}

?>



What I have tried:

Hello
I'm a PHP code to C # Converter can someone do that?

<center>
<form method="post"> 
<br />
<textarea id="url" name="url_form" cols="40" rows="8" style="width: 400px">
</textarea >
<br />
<input type="submit" style="margin-top: 5px; font-size: 18px" value="Check" />
</form>
</center>

<?php

if($_REQUEST['url_form']) {
$urls = trim($_POST['url_form']);
$urls = explode("\n", $urls);
$urls = array_filter($urls, 'trim');
}

if(!$urls) {
	exit;
}

?>

<div style="margin: auto; width: 50%; min-width: 400px">
<table width="500" cellpadding="5" cellspacing="5">
    <thead style="text-align: left">
        <tr>
            <th>ID</th>
            <th>URL</th>
            <th>DA</th>
            <th>PA</th>
            <th>MR</th>
            <th>EL</th>
        </tr>
    </thead>
    <tbody>

<?php

$check_count = 0;
$urls_metrics = array();

$chunked_verified_urls = array_chunk($urls,80);

foreach($chunked_verified_urls as $chunk_section) {
	
	sleep(2);
	unset($url);
	$url = $chunk_section;

	$seomoz_metrics = getSeomozMetrics($url);
	
	if($seomoz_metrics['error'] != '') {
		echo "Error[SEOMoz]: ".$seomoz_metrics['error']."<br>";
	} else {
		foreach($seomoz_metrics as $index => $seomoz_metric) {
			
			$url_metrics['pa'] = number_format($seomoz_metric['pa'], 0, '.', '');
			$url_metrics['url'] = $seomoz_metric['url'];
			$url_metrics['da'] = number_format($seomoz_metric['da'], 0, '.', '');
			$url_metrics['title'] = $seomoz_metric['title'];
			$url_metrics['external_links'] = $seomoz_metric['external_links'];
			$url_metrics['mozrank'] = number_format($seomoz_metric['mozrank'], 2, '.', '');
			$check_count  ;
			
			echo "<tr><td>";
				echo $check_count;
			echo "</td><td>";
				echo str_replace("http://","",$url_metrics['url']);
			echo "</td><td>";
				echo $url_metrics['da'];
			echo "</td><td>";
				echo $url_metrics['pa'];
			echo "</td><td>";
				echo $url_metrics['mozrank'];
			echo "</td><td>";
				echo $url_metrics['external_links'];
			echo "</td>";
			echo "</tr>";

			$urls_metrics[] = $url_metrics;
        }
	}
}
?>

</tbody></table>

</div>

<?php

function getSeomozMetrics($objectURL) {
		
		$accessID = "accessID";
		
		$secretKey = "secretKey";
	
		$expires = time()   600;

		$stringToSign = $accessID."\n".$expires;
		 
		$binarySignature = hash_hmac('sha1', $stringToSign, $secretKey, true);
		
		$urlSafeSignature = urlencode(base64_encode($binarySignature));	 
	
		$cols = 68719476736 34359738368 536870912 32768 16384 2048 32 4;
		 
		$requestUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
		 
		$batchedDomains = $objectURL;
		$encodedDomains = json_encode($batchedDomains);
	
		$options = array(
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_POSTFIELDS     => $encodedDomains
			);
		 
		$ch = curl_init($requestUrl);
		curl_setopt_array($ch, $options);
		$content = curl_exec($ch);
		curl_close( $ch );
		 
		$response = json_decode($content,true);
		
		$count = 0;

    if (isset($response['error_message'])) {
        $metric_list = array('error'=>$response['error_message']);
    } else {
	
        foreach($response as $site_metric) {
			
			$metric_list[$count]['url'] = $objectURL[$count];
			$metric_list[$count]['subdomain'] = $site_metric['ufq'];
           $metric_list[$count]['domain'] = $site_metric['upl'];
           $metric_list[$count]['pa'] = $site_metric['upa'];
           $metric_list[$count]['da'] = $site_metric['pda'];
           $metric_list[$count]['mozrank'] = $site_metric['umrp'];
           $metric_list[$count]['title'] = $site_metric['ut'];
           $metric_list[$count]['external_links'] = $site_metric['ueid'];
			$count  ;  
        }
    }
	return $metric_list;	
}

?>

解决方案

_REQUEST['url_form']) {


urls = trim(


_POST['url_form']);


这篇关于将代码PHP转换为C#windows forme应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆