WeChat公衆プラットフォームAPIインターフェース拡張パッケージ

25463 ワード

転載先:http://www.thinkphp.cn/extend/295.html
wechat.class.phpは公式APIを呼び出し、APIの各機能を細分化し、チェーン呼び出しをサポートします.
wechatext.class.phpは非公式APIであり、アカウントとパスワードを設定する必要があり、能動的なポイント対マイクロメッセージとバッチ送信を実現することができます.この方式は長期的な有効性を保証しません.
Thinkphp環境ではORGディレクトリに入れて、importメソッドで呼び出すことができます.
もっと詳しい情報と更新はプロジェクトgithubアドレスにアクセスできます.forkを歓迎します.
https://github.com/dodgepudding/wechat-php-sdk
基本API呼び出し例:
  1. include "wechat.class.php"
  2. $options = array(
  3.     'token'=>'tokenaccesskey' // key
  4.  );
  5. $weObj = new Wechat($options);
  6. $weObj->valid();
  7. $type = $weObj->getRev()->getRevType();
  8.  switch($type) {
  9.  case Wechat::MSGTYPE_TEXT:
  10.         $weObj->text("hello, I'm wechat")->reply();
  11.         exit;
  12.         break;
  13.  case Wechat::MSGTYPE_EVENT:
  14.         break;
  15.  case Wechat::MSGTYPE_IMAGE:
  16.         break;
  17.  default:
  18.         $weObj->text("help info")->reply();
  19.  }
:
  1. include("wechatext.class.php");
  2.  function logdebug($text){
  3.     file_put_contents('./data/log.txt',$text."
    "
    ,FILE_APPEND);     
  4.  };
  5. $options = array(
  6.     'account'=>'[email protected]',
  7.     'password'=>'demo',
  8.     'datapath'=>'./data/cookie_',
  9.         'debug'=>true,
  10.         'logcallback'=>'logdebug'   
  11.  ); 
  12. $wechat = new Wechatext($options);
  13.  if ($wechat->checkValid()) {
  14.     // 
  15.     $data = $wechat->getInfo('3974200');
  16.     // 
  17.     //$wechat->send('3974200','hello '.time());
  18.     var_dump($data);
  19.  }
1.1 :
Wechatext API( )
:
* send($id,$content) id
* batch($ids,$content)
* sendNews($account,$title,$summary,$content,$pic,$srcurl='')

Wechatauth API

http://blog.4wer.com/wechat-php-sdk
:
* get_login_code() ,
* get_code_image($code='')
* verify_code() , 200 .
* get_login_cookie()
* sendNews($account,$title,$summary,$content,$pic,$srcurl='')