C # key code to open a PHP link pass and receive a return value _c# tutorial

Source: Internet
Author: User

PHP code

First, PHP

<?php 
Header ("Content-type:text/html;charset=utf-8"); 
$u =$_post[' zdupdate '];
$p =$_post[' pid '];
$a =$_post["Afid"];
$d =$_post["Dtime"];
Require ('.. /db/conn.php ');//Open 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 ";
}
? >

Second, C # code

String poststring = "zdupdate=y&pid=" + dt. rows[i]["Pid". ToString () + "&afid=" + dt. rows[i]["Affiateid"]. ToString () + "&dtime=" + dt. rows[i]["Dtime"]. ToString () + "";//Here is the passed parameter, can be used to grasp the package analysis, can also analyze their own, mainly in the form inside every name should be added 
byte[] postdata = Encoding.UTF8.GetBytes ( poststring)//encoding, especially Chinese characters, in advance to see the encoding of the crawl page 
string url = "http://haibook.pnxchina.com/api/index.php";//Address 
WebClient WebClient = new WebClient ();
WEBCLIENT.HEADERS.ADD ("Content-type", "application/x-www-form-urlencoded");/the header that must be added to the Post method, If you change to get way, then remove this sentence can 
byte[] responsedata = webclient.uploaddata (URL, "POST", postdata);/Gets the return character stream 

The above is a small set to introduce C # for you to open the PHP link and then receive the return value of the key code, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.