?إذا كنت تشعر أن هذا المشروع جيد، الرجاء الضغط على الزاوية اليمنى العليا من المشروع لتشجيع المؤلف، شكرا لك؟.
wecom-sdk هو تطبيق Java لمؤسسة WeChat المفتوحة المصدر وهو حاليًا تطبيق Java مفتوح المصدر الأكثر اكتمالاً. بعد ما يقرب من ثلاث سنوات من التكرار، تم تنفيذ واجهات WeChat المفتوحة للمؤسسات مثل إدارة دفتر العناوين وإدارة العملاء وخدمة عملاء WeChat وإدارة المواد ودفع الرسائل وروبوتات المؤسسة والتحقق من الهوية وإدارة التطبيقات ومكتب الوصول المفتوح والدفع المؤسسي يمكنك الوصول بسرعة وبشكل أنيق إلى WeChat الخاص بالشركة دون تكاليف تعليمية عالية.
/**
* 企微机器人
*
* @throws IOException the io exception
*/
@ Test
void webHooks () throws IOException {
// 发 markdown
WebhookBody markdownBody = WebhookMarkdownBody . from ( "这里为markdown消息" );
// 发纯文本
WebhookBody textBody = WebhookTextBody . from ( "这里为纯文本" );
// 发图文
WebhookArticle article = new WebhookArticle ( "这里为标题" , "这里为图文链接" )
. picurl ( "这里为封面图链接" )
. description ( "这里为摘要信息" );
WebhookBody newsBody = WebhookNewsBody . from ( Collections . singletonList ( article ));
// 从base64发图片
String base64 = "图片base64" ;
String md5 = "图片base64的md5" ;
WebhookBody imageBody1 = WebhookImageBody . from ( base64 , md5 );
// 从流发送图片
String path = "C: \ Users \ Administrator \ Desktop \ 0.png" ;
InputStream inputStream = Files . newInputStream ( Paths . get ( path ));
WebhookBody imageBody2 = WebhookImageBody . from ( inputStream );
WeComResponse weComResponse = WorkWeChatApi . webhookApi (). send ( "机器人key" , markdownBody );
Assertions . assertTrue ( weComResponse . isSuccessful ());
}
راجع SpringBootWecomSdkTests.java لمزيد من الأمثلة
في الوقت الحاضر، يمكن تكييف التطبيقات ذاتية البناء بسهولة، لكن مقدمي الخدمات ومطوري الوكالات ليسوا مفتوحي المصدر في الوقت الحالي.
2.11.0
4.12.0
3.1.8
2.15.2
1.4.20
< dependency >
< groupId >cn.felord</ groupId >
< artifactId >wecom-sdk</ artifactId >
< version >1.3.2</ version >
</ dependency >
< dependency >
< groupId >cn.felord</ groupId >
< artifactId >rx-wecom-sdk</ artifactId >
< version >1.3.2</ version >
</ dependency >
نظرًا لأن التنفيذ مكتمل جدًا، إذا كنت تريد العثور على واجهة برمجة التطبيقات بدقة، فيمكنك القيام بذلك:
public interface TagApi {
/**
* 创建标签
*
* @param request the request
* @return GenericResponse generic response
* @throws WeComException the weComException
*/
@ POST ( "tag/create" )
GenericResponse < String > createTag ( @ Body Tag request ) throws WeComException ;
}
انتقل أولاً إلى وثائق Enterprise WeChat API للعثور على واجهة برمجة التطبيقات التي تحتاجها، مثل إنشاء علامة https://qyapi.weixin.qq.com/cgi-bin/tag/create?access_token=ACCESS_TOKEN
tag/create
البحث على مستوى العالم.
تم الإبلاغ عن خطأ NoSuchMethod لأن مشروعك نفسه قد قدم Okhttp، ولكن الإصدار منخفض نسبيًا، مما يؤدي إلى عدم التوافق. يمكنك تقديم wecom-sdk من خلال التبعيات التالية.
< dependency >
< groupId >cn.felord</ groupId >
< artifactId >wecom-sdk</ artifactId >
< version >1.3.2</ version >
< exclusions >
< exclusion >
< groupId >com.squareup.okhttp3</ groupId >
< artifactId >okhttp</ artifactId >
</ exclusion >
< exclusion >
< groupId >com.squareup.okhttp3</ groupId >
< artifactId >logging-interceptor</ artifactId >
</ exclusion >
</ exclusions >
</ dependency >
< dependency >
< groupId >com.squareup.okhttp3</ groupId >
< artifactId >okhttp</ artifactId >
< version >4.12.0</ version >
</ dependency >
< dependency >
< groupId >com.squareup.okhttp3</ groupId >
< artifactId >logging-interceptor</ artifactId >
< version >4.12.0</ version >
</ dependency >
لا مزيد من التوثيق، الكود هو التوثيق