雷火电竞-中国电竞赛事及体育赛事平台

歡迎來到入門教程網(wǎng)!

C#教程

當(dāng)前位置:主頁 > 軟件編程 > C#教程 >

C#打開php鏈接傳參然后接收返回值的關(guān)鍵代碼

來源:本站原創(chuàng)|時間:2020-01-10|欄目:C#教程|點擊:

php代碼

一、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');//打開文件
$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";
}
?>

二、C#代碼

string postString = "zdupdate=Y&pid=" + dt.Rows[i]["Pid"].ToString() + "&afid=" + dt.Rows[i]["affiateid"].ToString() + "&dtime=" + dt.Rows[i]["Dtime"].ToString() + "";//這里即為傳遞的參數(shù),可以用工具抓包分析,也可以自己分析,主要是form里面每一個name都要加進來 
byte[] postData = Encoding.UTF8.GetBytes(postString);//編碼,尤其是漢字,事先要看下抓取網(wǎng)頁的編碼方式 
string url = "http://haibook.pnxchina.com/api/index.php";//地址 
WebClient webClient = new WebClient();
webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");//采取POST方式必須加的header,如果改為GET方式的話就去掉這句話即可 
byte[] responseData = webClient.UploadData(url, "POST", postData);//得到返回字符流 
string srcString = Encoding.UTF8.GetString(responseData);//解碼 

以上所述是小編給大家介紹的C#打開php鏈接傳參然后接收返回值的關(guān)鍵代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對我們網(wǎng)站的支持!

上一篇:C# Windows API應(yīng)用之基于FlashWindowEx實現(xiàn)窗口閃爍的方法

欄    目:C#教程

下一篇:C# Windows API應(yīng)用之基于GetDesktopWindow獲得桌面所有窗口句柄的方法

本文標(biāo)題:C#打開php鏈接傳參然后接收返回值的關(guān)鍵代碼

本文地址:http://www.jygsgssxh.com/a1/C_jiaocheng/6291.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有