php的代码 转换成 c#
<?php4include_once("WxPayHelper.php");56//1.获取accesstoken7$appid="wx0000000000000000"...
<?php
4 include_once("WxPayHelper.php");
5
6 //1. 获取access token
7 $appid = "wx0000000000000000";
8 $appsecret = "e76050733ce76050733ce76050733cdd";
9 $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";
10 $result = https_request($url);
11 $jsoninfo = json_decode($result, true);
12 $access_token = $jsoninfo["access_token"];
13
14 //2.准备参数
15 $deliver_timestamp = time();
16 //2.1构造最麻烦的app_signature
17 $obj['appid'] = $appid;
18 $obj['appkey'] = "8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6k";
19 $obj['openid'] = "o0pk9uIVnlY-fJkzFKEbQ6LJ4cFc";
20 $obj['transid'] = "1218614901201405273313473135";
21 $obj['out_trade_no'] = "JfuKdiBig4zZnE4n";
22 $obj['deliver_timestamp'] = $deliver_timestamp;
23 $obj['deliver_status'] = "1";
24 $obj['deliver_msg'] = "ok";
25
26 $WxPayHelper = new WxPayHelper();
27 //get_biz_sign函数受保护,需要先取消一下,否则会报错
28 $app_signature = $WxPayHelper->get_biz_sign($obj);
29
30 //3. 将构造的json提交给微信服务器,查询
31 $jsonmenu = '
32 {
33 "appid" : "'.$obj['appid'].'",
34 "openid" : "'.$obj['openid'].'",
35 "transid" : "'.$obj['transid'].'",
36 "out_trade_no" : "'.$obj['out_trade_no'].'",
37 "deliver_timestamp" : "'.$deliver_timestamp.'",
38 "deliver_status" : "'.$obj['deliver_status'].'",
39 "deliver_msg" : "'.$obj['deliver_msg'].'",
40 "app_signature" : "'.$app_signature.'",
41 "sign_method" : "sha1"
42 }';
43
44
45
46 $url = "https://api.weixin.qq.com/pay/delivernotify?access_token=".$access_token;
47 $result = https_request($url, $jsonmenu);
48 var_dump($result);
49
50 function https_request($url, $data = null){
51 $curl = curl_init();
52 curl_setopt($curl, CURLOPT_URL, $url);
53 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
54 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
55 if (!empty($data)){
56 curl_setopt($curl, CURLOPT_POST, 1);
57 curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
58 }
59 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
60 $output = curl_exec($curl);
61 curl_close($curl);
62 return $output;
63 } 展开
4 include_once("WxPayHelper.php");
5
6 //1. 获取access token
7 $appid = "wx0000000000000000";
8 $appsecret = "e76050733ce76050733ce76050733cdd";
9 $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";
10 $result = https_request($url);
11 $jsoninfo = json_decode($result, true);
12 $access_token = $jsoninfo["access_token"];
13
14 //2.准备参数
15 $deliver_timestamp = time();
16 //2.1构造最麻烦的app_signature
17 $obj['appid'] = $appid;
18 $obj['appkey'] = "8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6kxCRvdJENpWpw8mruTNOGeX8OVUlIYxIyw6k";
19 $obj['openid'] = "o0pk9uIVnlY-fJkzFKEbQ6LJ4cFc";
20 $obj['transid'] = "1218614901201405273313473135";
21 $obj['out_trade_no'] = "JfuKdiBig4zZnE4n";
22 $obj['deliver_timestamp'] = $deliver_timestamp;
23 $obj['deliver_status'] = "1";
24 $obj['deliver_msg'] = "ok";
25
26 $WxPayHelper = new WxPayHelper();
27 //get_biz_sign函数受保护,需要先取消一下,否则会报错
28 $app_signature = $WxPayHelper->get_biz_sign($obj);
29
30 //3. 将构造的json提交给微信服务器,查询
31 $jsonmenu = '
32 {
33 "appid" : "'.$obj['appid'].'",
34 "openid" : "'.$obj['openid'].'",
35 "transid" : "'.$obj['transid'].'",
36 "out_trade_no" : "'.$obj['out_trade_no'].'",
37 "deliver_timestamp" : "'.$deliver_timestamp.'",
38 "deliver_status" : "'.$obj['deliver_status'].'",
39 "deliver_msg" : "'.$obj['deliver_msg'].'",
40 "app_signature" : "'.$app_signature.'",
41 "sign_method" : "sha1"
42 }';
43
44
45
46 $url = "https://api.weixin.qq.com/pay/delivernotify?access_token=".$access_token;
47 $result = https_request($url, $jsonmenu);
48 var_dump($result);
49
50 function https_request($url, $data = null){
51 $curl = curl_init();
52 curl_setopt($curl, CURLOPT_URL, $url);
53 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
54 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
55 if (!empty($data)){
56 curl_setopt($curl, CURLOPT_POST, 1);
57 curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
58 }
59 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
60 $output = curl_exec($curl);
61 curl_close($curl);
62 return $output;
63 } 展开
2个回答
展开全部
Phalanger 是PHP的.NET编译 器;也就是能将PHP程序代码编译成.NET平台的MSIL。Phalanger早在2005年就开始由一群捷克的计算机系学生动手开发。
Phalanger与PHP 5.0兼容,并且能结合PHP和.NET两者的对象,例如可以从.NET程序使用PHP开发的类库,或者以PHP程序使用C#或VB.NET开发的类库 (当然,这种PHP程序必须以Phalanger编译);Phalanger最广泛的应用就是将PHP网页编译成ASP.NET网页,此外也能够用PHP 编写WinForms程序。最近才发布的2.0测试版beta3的Phalanger,最大的改进是完整支持.NET Framework 2.0。
在CodeProject上有一篇文章介绍Phalanger, PHP for .NET: Introduction for .NET developers 。文章比较长,注意一点就是(http://www.php-compiler.net/) 网站所使用的Wiki程序 DokuWiki 就是PHP程序通过Phalanger运行在.NET上,你应该很有兴趣去看看,感受一下.NET下的动态语言。
http://www.oschina.net/p/phalanger
Phalanger与PHP 5.0兼容,并且能结合PHP和.NET两者的对象,例如可以从.NET程序使用PHP开发的类库,或者以PHP程序使用C#或VB.NET开发的类库 (当然,这种PHP程序必须以Phalanger编译);Phalanger最广泛的应用就是将PHP网页编译成ASP.NET网页,此外也能够用PHP 编写WinForms程序。最近才发布的2.0测试版beta3的Phalanger,最大的改进是完整支持.NET Framework 2.0。
在CodeProject上有一篇文章介绍Phalanger, PHP for .NET: Introduction for .NET developers 。文章比较长,注意一点就是(http://www.php-compiler.net/) 网站所使用的Wiki程序 DokuWiki 就是PHP程序通过Phalanger运行在.NET上,你应该很有兴趣去看看,感受一下.NET下的动态语言。
http://www.oschina.net/p/phalanger
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询