예제 #1
0
<?php

header("Content-Type:text/xml");
$data = json_decode($_POST['data'], true);
$Wx = new Weixin($data);
$rst = $Wx->send();
echo $rst;
class Weixin
{
    public function __construct($data)
    {
        $this->url = $data["url"];
        $this->token = $data["token"];
        $this->data = $data;
    }
    private function makeMsg()
    {
        $msg = $this->data['data'];
        $xml = $this->xmlItemPack("xml", $msg);
        $xmlDoc = new SimpleXMLElement($xml);
        return $xmlDoc->asXML();
    }
    public function xmlItemPack($k, $v)
    {
        $head = "<" . $k . ">";
        $foot = "</" . $k . ">";
        if (is_string($v)) {
            $tpl = $head . "<![CDATA[" . $v . "]]>" . $foot;
        } else {
            if (is_numeric($v)) {
                $tpl = $head . $v . $foot;
예제 #2
0
<?php

define('UID', '1024');
include 'weixin.php';
$weixin = new Weixin();
$result = $weixin->getInfo();
echo $weixin->send('Wesley-zhou', 'done!');