<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>运达&#039;s  blog &#187; 接口</title>
	<atom:link href="https://www.yunda51.com/?feed=rss2&#038;tag=%E6%8E%A5%E5%8F%A3" rel="self" type="application/rss+xml" />
	<link>https://www.yunda51.com</link>
	<description>运达的博客</description>
	<lastBuildDate>Wed, 12 Nov 2025 07:58:26 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.19</generator>
	<item>
		<title>CURL模拟进行微信接口的GET与POST</title>
		<link>https://www.yunda51.com/?p=1475</link>
		<comments>https://www.yunda51.com/?p=1475#comments</comments>
		<pubDate>Wed, 31 Dec 2014 06:38:16 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[Post]]></category>
		<category><![CDATA[微信]]></category>
		<category><![CDATA[接口]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1475</guid>
		<description><![CDATA[Get提交获取数据 /** * @desc 获取access_token * @return String a<a href="https://www.yunda51.com/?p=1475" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p><strong>Get提交获取数据</strong></p>
<pre class="wp-code-highlight prettyprint">
           /** 
            * @desc 获取access_token 
            * @return String access_token 
            */  
           function getAccessToken(){  
               $AppId = &#039;1232assad13213123&#039;;  
               $AppSecret = &#039;2312312321adss3123213&#039;;  
               $getUrl = &#039;https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&amp;appid=&#039;.$AppId.&#039;&amp;secret=&#039;.$AppSecret;  
               $ch = curl_init();  
               curl_setopt($ch, CURLOPT_URL, $getUrl);  
               curl_setopt($ch, CURLOPT_HEADER, 0);  
               curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
               curl_setopt($ch, CURL_SSLVERSION_SSL, 2);  
               curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);  
               curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);  
               $data = curl_exec($ch);  
               $response = json_decode($data);  
               return $response-&gt;access_token;  
           }  
</pre>
<p><strong>Post提交获取数据</strong></p>
<pre class="wp-code-highlight prettyprint">
            /** 
             * @desc 实现天气内容回复 
             */  
            public function testWeixin(){  
                $access_token = $this-&gt;getAccessToken();  
                $customMessageSendUrl = &#039;https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=&#039;.$access_token;  
                $description = &#039;今天天气的详细信息（从第三方获取）。&#039;;  
                $url = &#039;http://weather.com/&#039;;  
                $picurl = &#039;http://weather.com/&#039;;  
                $postDataArr = array(  
                    &#039;touser&#039;=&gt;&#039;OPENID&#039;,  
                    &#039;msgtype&#039;=&gt;&#039;news&#039;,  
                    &#039;news&#039;=&gt;array(  
                        &#039;articles&#039;=&gt;array(  
                            &#039;title&#039;=&gt;&#039;当天天气&#039;,  
                            &#039;description&#039;=&gt;$description,  
                            &#039;url&#039;=&gt;$url,  
                            &#039;picurl&#039;=&gt;$picurl,  
                        ),  
                    ),  
                );  
                $postJosnData = json_encode($postDataArr);  
                $ch = curl_init($customMessageSendUrl);      
                curl_setopt($ch, CURLOPT_HEADER, 0);      
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);      
                curl_setopt($ch, CURLOPT_POST, 1);      
                curl_setopt($ch, CURLOPT_POSTFIELDS, $postJosnData);    
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);  
                curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);  
                $data = curl_exec($ch);      
                var_dump($data);  
            }  
</pre>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href="http://www.yunda51.com/1475.html">http://www.yunda51.com/1475.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1475</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
