-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
107 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
`WeChatSDK`其他语言接口文档。 | ||
|
||
## Python | ||
|
||
发布`Python`版本的接口,具体使用见`src/WeChatSDKPy/sdk.py`。 | ||
|
||
``` | ||
//需管理员运行python | ||
wxsdk = WXSDK() | ||
print(wxsdk.WXOpenWechat()) | ||
input("wait for...") | ||
print(wxsdk.WXIsWechatAlive()) | ||
print(wxsdk.WXIsWechatSDKOk()) | ||
print(wxsdk.WXInitialize()) | ||
input("wait for...") | ||
print(wxsdk.WXSendTextMsg("wxid_n11111", "This is a python sdk test msg")) | ||
``` | ||
|
||
## Java | ||
|
||
发布`Java`版本的接口,具体使用见`src/WeChatSDKJava/WeChatSDK.java`和`TestJavaSDK.java`。 | ||
|
||
由于`Java`接口使用了`jna`,所以需要下载[jna.jar](http://repo1.maven.org/maven2/net/java/dev/jna/jna/5.2.0/jna-5.2.0.jar),具体编译方法请查找`Java`相关文章。 | ||
|
||
``` | ||
//需管理员运行java | ||
public class TestJavaSDK { | ||
public static void main(String[] argv) throws Exception { | ||
System.out.println("hello java WechatSDK"); | ||
int pid = WeChatSDK.sdk.WXOpenWechat(); | ||
if(pid <= 0) { | ||
System.out.println("hello java WechatSDK"); | ||
return; | ||
} | ||
System.out.println("pid: " + pid); | ||
System.out.println("wait for..."); | ||
System.in.read(); | ||
System.out.println(WeChatSDK.sdk.WXIsWechatAlive(pid)); | ||
System.out.println(WeChatSDK.sdk.WXIsWechatSDKOk(pid)); | ||
System.out.println(WeChatSDK.sdk.WXInitialize(pid)); | ||
System.out.println("wait for..."); | ||
System.in.read(); | ||
System.out.println(WeChatSDK.sdk.WXSendTextMsg(pid, new WString("wxid_11111"), new WString("This is a java sdk test msg"))); | ||
System.in.read(); | ||
} | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import com.sun.jna.Library; | ||
import com.sun.jna.WString; | ||
|
||
//https://www.cnblogs.com/huangzijian/p/6638710.html | ||
|
||
public class TestJavaSDK { | ||
public static void main(String[] argv) throws Exception { | ||
System.out.println("hello java WechatSDK"); | ||
|
||
int pid = WeChatSDK.sdk.WXOpenWechat(); | ||
if(pid <= 0) { | ||
System.out.println("hello java WechatSDK"); | ||
return; | ||
} | ||
|
||
System.out.println("pid: " + pid); | ||
|
||
System.out.println("wait for..."); | ||
System.in.read(); | ||
|
||
System.out.println(WeChatSDK.sdk.WXIsWechatAlive(pid)); | ||
System.out.println(WeChatSDK.sdk.WXIsWechatSDKOk(pid)); | ||
System.out.println(WeChatSDK.sdk.WXInitialize(pid)); | ||
System.out.println("wait for..."); | ||
System.in.read(); | ||
System.out.println(WeChatSDK.sdk.WXSendTextMsg(pid, new WString("wxid_xxxx"), new WString("This is a java sdk test msg"))); | ||
|
||
System.in.read(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import com.sun.jna.Library; | ||
import com.sun.jna.Native; | ||
import com.sun.jna.WString; | ||
|
||
//https://blog.csdn.net/gcangle/article/details/8504629 | ||
|
||
public interface WeChatSDK extends Library { | ||
WeChatSDK sdk = (WeChatSDK)Native.loadLibrary("WeChatSDK", WeChatSDK.class); | ||
public int WXOpenWechat(); | ||
public boolean WXIsWechatAlive(int pid); | ||
public int WXInitialize(int pid); | ||
public int WXUninitialize(int pid); | ||
public boolean WXIsWechatSDKOk(int pid); | ||
|
||
public int WXAntiRevokeMsg(int pid); | ||
public int WXUnAntiRevokeMsg(int pid); | ||
public int WXSaveVoiceMsg(int pid, WString path); | ||
public int WXUnSaveVoiceMsg(int pid); | ||
|
||
public int WXSendTextMsg(int pid, WString wxid, WString msg); | ||
} |