编译企业微信会话内容存档PHP版SDK扩展

1.下载SDK

如果克隆不了,就页面下载

git clone https://github.com/pangdahua/php7-wxwork-finance-sdk

2.下载企微官网C版本的最新sdk文件

  • 下载地址:https://wwcdn.weixin.qq.com/node/wework/images/sdk_20201116.rar

  • 下载以后将解压之后的文件夹里libWeWorkFinanceSdk_C.soWeWorkFinanceSdk_C.h复制到php7-wxwork-finance-sdk文件夹中。

3.编译之前准备

  • 将SDK文件夹上传至服务器,放在/usr/local/src下,即完整路径为/usr/local/src/php7-wxwork-finance-sdk
  • 在终端执行,设置临时变量
PHP_CONFIG="/usr/local/php/bin/php-config"
PHP_WXWORK_FINANCE_SDK="/usr/local/src/php7-wxwork-finance-sdk"

4.开始编译

PHP安装目录根据自己的实际场景修改,我的PHP安装在/usr/local/php

cd /usr/local/src/php7-wxwork-finance-sdk

# 生成configure文件
phpize   #如果phpize没有设置软连接,需要完整路径执行即/usr/local/php/bin/phize

# 开始编译
./configure --with-php-config=$PHP_CONFIG --with-wxwork-finance-sdk=$PHP_WXWORK_FINANCE_SDK

# 如果没有报错的话,就可以执行`make && make install`
.......
xwork_finance_sdk.so
creating wxwork_finance_sdk.la
(cd .libs && rm -f wxwork_finance_sdk.la && ln -s ../wxwork_finance_sdk.la wxwork_finance_sdk.la)
/bin/sh /usr/local/src/wxwork-finance/libtool --mode=install cp ./wxwork_finance_sdk.la /usr/local/src/wxwork-finance/modules
   ./.libs/wxwork_finance_sdk.so /usr/local/src/wxwork-finance/modules/wxwork_finance_sdk.so
cp ./.libs/wxwork_finance_sdk.lai /usr/local/src/wxwork-finance/modules/wxwork_finance_sdk.la
PATH="$PATH:/sbin" ldconfig -n /usr/local/src/wxwork-finance/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/src/wxwork-finance/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.
[root@test php7-wxwork-finance-sdk]# make install 
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20170718/

5.php.ini添加扩展

extension=wxwork_finance_sdk.so

你可能感兴趣的:(企业微信,php,linux)