Giter VIP home page Giter VIP logo

php7-wxwork-finance-sdk's Introduction

wxwork_finance_sdk_wrapper

企业微信-会话内容存档PHP扩展

依赖

企业微信提供的sdk;

PHP VERSION >= 7.0

  • 已支持 php8 感谢 @singee77 pr

openssl扩展

安装步骤及要求

       $INSATLL_PHP_PATH/bin/phpize
        
       ./configure --with-php-config=$INSTALL_PHP_PATH/php-config --with-wxwork-finance-sdk=$WXWORK_FINANCE_C_SDK_PATH
       
        make && make install
php.ini 增加 extension=wxwork_finance_sdk.so

API

    WxworkFinanceSdkExcption::__construct();
    WxworkFinanceSdk::__construct(string $corpId, string $secret, array $options);
    string $corpId 企业号

    string $secret 秘钥

    array $options = [ // 可选参数
        'proxy_host' => string,
        'proxy_password' => string,
        'timeout' => 10, // 默认超时时间为10s
    ]
   string WxworkFinanceSdk::getChatData(int $seq, int $limit);
    * 拉取聊天数据
    $seq 起始位置
    $limit 获取条数
   bool WxworkFinanceSdk::downloadMedia(string $sdkfileid, string $saveTo)
   * 下载资源
   $sdkfileid 资源id。来自chat 中的数据sdkfileid
   $saveTo 本地保存的路径
   array WxworkFinanceSdk::getMediaData(string $sdkfileid, string $indexBuf='');
   * 拉取静态资源数据,用于可以支持追加模式的三方存储平台
   返回的数据结构体
   $ret = [
       'data' => '' // string 返回的数据
       'nextIndex' => 'ddd' // string 获取下一段数据的句柄
       'isFinished' => int // 1 数据已拉取完毕 
   ];
   
   
  • 感谢 @zhanzhaopeng1 PR
       string WxworkFinanceSdk::decryptData(string $randomKey, string $encryptStr);
       * 解密数据
       $randomKey 通过openssl解密后的key
       $encryptStr chats 的加密数据

已知问题

  1. free(): invalid pointer
   * 定位intl扩展的冲突问题. php -m |grep intl 建议重新编译php 取消intl扩展
   
  2. 与swoole的扩展冲突
   * 优先加载wxwork_finance_sdk.so 后加载swoole 【@tisswb】

示例

wxwork_finance_sdk.php

Alipay

php7-wxwork-finance-sdk's People

Contributors

pangdahua avatar singee77 avatar zhanzhaopeng1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

php7-wxwork-finance-sdk's Issues

在项目中使用报错

您好,我这边扩展安装好了,还需要在代码中如何配置?我直接用你写的demo,会直接报错:致命错误: Class 'app\admin\controller\WxworkFinanceSdk' not found。

有时候会报access token missing

问题:有时候会报access token missing,持续一小时左右,然后就会自己恢复。
排查步骤:

  1. secret跟corp id填写没问题
  2. 使用的laravels(swoole),常驻进程拉取,维护的全局单例,不存在频繁初始化sdk的现象

困扰了很久了,使用多种其它方案重写,但是都没解决

centos8,PHP7.4.4安装完成之后报错

腾讯未提供PHP的JSSDK,非常感谢您开发这个PHP应用,但我在安装的过程中遇到了一些问题:
1、我的环境:Centos8,PHP版本7.4.4
2、使用企业微信提供的SDK版本,1.0和1.1,2版都尝试过,可以成功编译出来.co文件,当从php.ini中引入时,我执行php -m,查看扩展时以下错误,同时用PHP代码也测试了,跑不通;
#php -m
free(): invalid pointer Aborted (core dumped)

sdk问题

大佬,我的sdk已经按照文档对接完成,企业微信也有返回,传参都没有问题的,chatdata返回的是空数组,不知道怎么回事

安装完后,重启php报错,请问怎么解决

07-May-2021 17:06:30] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'C_sdk/libWeWorkFinanceSdk_C.so' (tried: C_sdk/libWeWorkFinanceSdk_C.so (C_sdk/libWeWorkFinanceSdk_C.so: cannot open shared object file: No such file or directory), /www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/C_sdk/libWeWorkFinanceSdk_C.so.so (/www/server/php/73/lib/php/extensions/no-debug-non-zts-20180731/C_sdk/libWeWorkFinanceSdk_C.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

同时给多家企业拉取的时候,在php中new sdk class,结果返回是上一个实例的会话存档拉取结果

  1.    $obj1 = new WxworkFinanceSdkUtil($corpId1,  $secret1, [
         "proxy_host" => "",
     "proxy_password" => "",
         "timeout" => 30,
     ]);
    

$obj2 = new WxworkFinanceSdkUtil($corpId2, $secret2, [
"proxy_host" => "",
"proxy_password" => "",
"timeout" => 30,
]);

$obj2 ->getChatData($seq, 1); // 这里获取到的是obj1企业的数据

ps: sdk版本升级无效,
image
新老版本均有
(感谢大佬)

WxworkFinanceSdk无法调用

现在服务框架为tp5
已执行完phpize && configure && make && make install.
image
无错误
调用时无WxworkFinanceSdk方法

downloadMedia

[voice] => Array
  (
  [md5sum] => 4ed970e4d640b495e740bad968aed5c9
  [voice_size] => 1266
  [play_length] => 2
  [sdkfileid] => CpsBKjAqWGpub1lmM3RsaWVUN0N6TTZBSTVmZS9ITTVGN1VNQU1jaTlES29GVnVMWldzdTltK251WklhbUFCcjYrZldyVGlReExaSXhNOVl2T3pKWlAwMWQ3MWV1NjlYaGpPYzJ2bTRWeUkzMzMxRkYwWWxlZzBrb3lDb1k4M1VZK0NDMGJxMWtleUpPTllQT3NCUUIzWVIzbUR3PT0SNE5EZGZOemc0TVRNd016TXpOakEwTWpjNU1GODVNemsyTmpnNU9WOHhOVGsxTXpJeU9ERTIaIDc5N2E2Nzc2NzI2NzcwNzQ2ZTc2NjE2ZjczNzc2Yzc4
  )
 

$sdkFileId = $xxx['voice']['sdkfileid'];

$obj->downloadMedia($sdkFileId, "/tmp/download");

//返回string(4) "Open"  int(0)

麻烦再问一下,这是什么原因,是因为我用体验版,下载不了吗

安装扩展失败?

请问$INSATLL_PATH_PATH/这个是指php的安装路径?$WXWORK_FINANCE_C_SDK_PATH这个是指你这个项目在服务器上的安装路径还是需要下载企业微信会话存档sdk的c语言版的路径?

php8.0 安装后警告

Warning: Missing arginfo for confirm_wxwork_finance_sdk_compiled() in Unknown on line 0

Warning: Missing arginfo for WxworkFinanceSdk::__construct() in Unknown on line 0

Warning: Missing arginfo for WxworkFinanceSdk::getChatData() in Unknown on line 0

Warning: Missing arginfo for WxworkFinanceSdk::decryptData() in Unknown on line 0

Warning: Missing arginfo for WxworkFinanceSdk::downloadMedia() in Unknown on line 0

Warning: Missing arginfo for WxworkFinanceSdk::getMediaData() in Unknown on line 0

wxwork 与 Swoole 有冲突,free(): invalid pointer

没有 intl 扩展

user@server:/etc/php/7.4/cli $ php -m
[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gettext
hash
iconv
igbinary
json
libxml
openssl
pcntl
pcre
PDO
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wxwork_finance_sdk
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zlib

[Zend Modules]
Zend OPcache

安装 swoole 后提示

user@server:/etc/php/7.4/cli$ php -m
free(): invalid pointer
已放弃 (核心已转储)

Swoole环境下数据错乱

在Swoole环境下 我用两家企业for循环实例化sdk调用 两家企业的sdk是两个实例, 但getChatData接口获取的加密消息数据两家企业是错乱的, 想问下是不支持协程环境么?

插件可以正常编译,无法正常加载

系统版本:
Ubuntu 18.04.4
PHP版本:
PHP 7.2.24

执行:
php --ri wxwork_finance_sdk

报错:
free(): invalid pointer
Aborted (core dumped)

编译是按文档流程编译的

执行./configure后报错

WeWorkFinanceSdk_C.h文件已经放到这个目录下/opt/php/lib/php/extensions/debug-zts-20180731/

执行 [root@localhost wxwork-sdk]# ./configure --with-php-config=/opt/php/bin/php-config --with-wxwork-finance-sdk=/opt/php/lib/php/extensions/debug-zts-20180731
就报 cannot find WeWorkFinanceSdk_C.h in path /opt/php/lib/php/extensions/debug-zts-20180731
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /opt/php
checking for PHP includes... -I/opt/php/include/php -I/opt/php/include/php/main -I/opt/php/include/php/TSRM -I/opt/php/include/php/Zend -I/opt/php/include/php/ext -I/opt/php/include/php/ext/date/lib
checking for PHP extension directory... /opt/php/lib/php/extensions/debug-zts-20180731
checking for PHP installed headers prefix... /opt/php/include/php
checking if debug is enabled... yes
checking if zts is enabled... yes
checking for re2c... re2c
checking for re2c version... 0.16 (ok)
checking for gawk... gawk
checking for wxwork_finance_sdk support... yes, shared
checking /opt/php/lib/php/extensions/debug-zts-20180731... configure: error: cannot find WeWorkFinanceSdk_C.h in path /opt/php/lib/php/extensions/debug-zts-20180731

使用插件报错

array(3) { ["errcode"]=> int(41001) ["errmsg"]=> string(167) "access_token missing, hint: [1595297094_45_a21af24b99541439ee],

php7.4 安装完后报错

free(): invalid pointer
/etc/init.d/php-fpm-74: line 53: 12152 Aborted (core dumped) $php_fpm_BIN --daemonize $php_opts

最新的master分支有bug

最新的master分支有bug , 在7.x版本下编译出文件调用就会报错 Segmentation fault, 使用tag 1.2.0版本的可以在PHP 7.x版本下编译文件没有问题。

文件路径报错

找不到文件的,可以将微信的C_sdk的目录拷贝到编译的目录下 ,然后指向 /目录/C_sdk,不是单独将.h文件拷贝过去就可以了。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.