SoFunction
Updated on 2025-03-06

C# opens the php link and passes parameters and receives the key code of the return value

php code

1. php

<?php 
header("Content-Type:text/html;charset=UTF-8"); 
$u=$_POST['zdupdate'];
$p=$_POST['pid'];
$a=$_POST["afid"];
$d=$_POST["dtime"];
require('../db/');//Open the file$sql_expire="insert into `m-haibook`.tbl_aff_log(aff_id,p_id,log_date,create_date) values($a,$p,'$d',now())";
if($u=='Y')
{ 
$myconn = mysql_connect($server_name, $db_username, $db_password);
mysql_select_db($db_name);
mysql_query("set names 'utf8'"); 
mysql_query($sql_expire);
print "1HHhh..1154QQwweeWW";
}
?>

2. C# code

string postString = "zdupdate=Y&pPid"].ToString() + "&afaffiateid"].ToString() + "&dtime=" + [i]["Dtime"].ToString() + "";//This is the passed parameters. You can use tools to capture package analysis or analyze it yourself. Mainly, every name in the form must be added.byte[] postData = Encoding.(postString);//Coding, especially Chinese characters, you need to check the encoding method of crawling web pages in advancestring url = "/api/";//addressWebClient webClient = new WebClient();
("Content-Type", "application/x-www-form-urlencoded");//If you use the POST method, you can remove this sentence if you change it to the GET method.byte[] responseData = (url, "POST", postData);//Get the return character streamstring srcString = Encoding.(responseData);//decoding 

The above is the key code for opening the php link to you C# to pass the parameters and then receiving the return value. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!