A kind of synchronous method for adjusting local address book and mapping wechat enterprise number address list
Technical field
The present invention relates to the synchronous method between field of network communication, especially local address book and wechat enterprise number.
Background technology
Traditional enterprise number third party's service exploitation, address book data is to be stored directly in Tencent's enterprise number server,
Daily maintenance and inquiry are carried out with the address list api for directly invoking Tencent, even if local also have preservation address book data,
Also be only preserved with the property of data backup, meanwhile, the regular regulation of wechat enterprise number cannot delete the department of member.
However this mode has the shortcomings that following, data source belongs to outer net at wechat enterprise number end, carries out data acquisition
When with safeguarding, it is necessary to pass through public network network, this will certainly expend excessive bandwidth, and when the bad situation of network environment
Under, it can be because the slow even malloc failure malloc of response speed causes various problem;Meanwhile it being tieed up at wechat enterprise number end
Shield, can be more complicated or inefficient when carrying out self-defined some more personalized functions of either developing.
It for above problem, then attempts to modify to address book data in local side, if it is desired to turning data source
Move on to the server of service provider local, it is to be ensured that the various functions of enterprise number service normal use, it is necessary to accomplish local
The address book data on address book data and enterprise number server on server is strictly reciprocity, and most direct way is exactly, often
One address book data of processing changes event, is all first to change local data, then above horse back synchronous vacations enterprise number,
But this mode often causes the chain rupture of synchronization process because of the X factors such as Network Abnormal or service fault, once two
For number of edges according to disconnecting, data are just constantly in nonsynchronous state.
Invention content
In order to solve the above technical problems, can adjust local address book the object of the present invention is to provide one kind and be mapped to micro-
Believe enterprise number address list so that the synchronous method of the stringent equity of both sides data.
The technical solution adopted by the present invention is:
A kind of synchronous method for adjusting local address book and mapping wechat enterprise number address list, includes the following steps:
A, in local self-defined communication directory structures;
B, member data is written according to address list structure in local;
C, triggering local address book is synchronized to the demapping instruction of wechat enterprise number address list;
D, wechat enterprise number establishes mapping tasks according to demapping instruction;
E, wechat enterprise number establishes backup groupings according to mapping tasks;
F, it is packaged the member data of full dose in current wechat enterprise number address list, and the member data of full dose is transferred to standby
Part grouping;
G, local that the asynchronous task notice that incremental data maps is initiated to wechat enterprise number, locally established with wechat enterprise number
Data synchronizing channel;
H, wechat enterprise number establishes address list structure mapping task according to asynchronous task notice;
I, local to generate local address book structured data;
J, local address book structured data is mapped on wechat enterprise number;
K, wechat enterprise number establishes address list member data mapping tasks;
L, local to generate local address book member data;
M, by local address book member data be mapped on wechat enterprise number and according to communication directory structures by address list at
Member's data are grouped;
N, wechat enterprise number establishes backup groupings membership synchronization's task;
O, the extra member data that local address book member data is not belonging in backup groupings is cleared up.
Local communication directory structures or member data are detected in step c with the presence or absence of variation, if so, triggering is local
Demapping instruction of the address list synchronization to wechat enterprise number address list;
Alternatively, clocked flip local address book is synchronized to the demapping instruction of wechat enterprise number address list.
Wechat enterprise number establishes mapping tasks according to demapping instruction in the step d, judges whether mapping tasks are created as
Work(, if success, enters step e, if failure, re-establishes or exit the program.
In the step k, before wechat enterprise number establishes address list member data mapping tasks, obtains communication directory structures and reflect
The readjustment of task is penetrated as a result, judging whether that successfully local address book structured data is mapped on wechat enterprise number, if success,
Address list member data mapping tasks are established in wechat enterprise number, if failure, return to step h.
In the step k, the number of failure, and default sample times N 1 are recorded, when the number of failure is more than sample
Number N1, then exit the program.In the step n, before wechat enterprise number establishes backup groupings membership synchronization's task, address list is obtained
The readjustment of member data mapping tasks is as a result, judge whether that local address book member data is successfully mapped to wechat enterprise number
On, if success, backup groupings membership synchronization's task is established in wechat enterprise number, if failure, return to step l.
In the step n, the number of failure, and default sample times N 2 are recorded, when the number of failure is more than sample
Number N2, then exit the program.
The local address book structured data locally generated in the step i is csv formatted files.
The local address book member data locally generated in the step l is csv formatted files.
Beneficial effects of the present invention:
The synchronous method of the present invention, modifies to address list in local, self-defined communication directory structures, and logical according to this
It interrogates directory structures and member data is written, local triggering is synchronized to the demapping instruction of wechat public platform, due to the characteristic of wechat public platform,
Backup groupings are first established, are packaged the member data of full dose in current wechat enterprise number address list, and the member data of full dose is turned
Backup groupings are moved on to, guarantees to modify to the communication directory structures in wechat enterprise number, can remove in wechat enterprise number
It is not belonging to the grouping of local communication directory structures, eliminates the obstacle that will appear conflict in full dose overwrite procedure, it locally will be local
Address list structured data is mapped in wechat public platform;Local address book member data is mapped to wechat public platform again at this time
In, and be grouped according to address list structured data, it finally clears up in backup groupings and is not belonging to local address book member data
Extra member data;The design is by local search and safeguards data speed faster, and performance is more preferable, has higher success rate;Together
When can ensure that local is consistent with wechat enterprise number both sides data, flexibility is more preferable, by local address book structural adjustment or
Person is self-defined to be applied on long-range wechat enterprise number address list.
Description of the drawings
The specific implementation mode of the present invention is described further below in conjunction with the accompanying drawings.
Fig. 1 is the general flow chart of the present invention.
Fig. 2 is the flow chart of the inquiry local address book of the present invention.
Specific implementation mode
As shown in Figure 1 and Figure 2, the design includes the following steps:
A, in local self-defined communication directory structures;
B, member data is written according to address list structure in local;
C, triggering local address book is synchronized to the demapping instruction of wechat enterprise number address list;
D, wechat enterprise number establishes mapping tasks according to demapping instruction;
E, wechat enterprise number establishes backup groupings according to mapping tasks;
F, it is packaged the member data of full dose in current wechat enterprise number address list, and the member data of full dose is transferred to standby
Part grouping;
G, local that the asynchronous task notice that incremental data maps is initiated to wechat enterprise number, locally established with wechat enterprise number
Data synchronizing channel;
H, wechat enterprise number establishes address list structure mapping task according to asynchronous task notice;
I, local to generate local address book structured data;
J, local address book structured data is mapped on wechat enterprise number;
K, wechat enterprise number establishes address list member data mapping tasks;
L, local to generate local address book member data;
M, by local address book member data be mapped on wechat enterprise number and according to communication directory structures by address list at
Member's data are grouped;
N, wechat enterprise number establishes backup groupings membership synchronization's task;
O, the extra member data that local address book member data is not belonging in backup groupings is cleared up.
Wherein, it in step a, according to customer service needs, can be carried out to the self-defined of communication directory structures at local computing end,
Local self-defined communication directory structures is more flexible, and fast, operable space is big.
In stepb, in local by data according to the customized communication directory structures person's of being written to data, it is possible to provide lead in batches
Enter, import template, data are written more rapidly, and operation is more simple.
In step c, local communication directory structures or member data are detected with the presence or absence of variation, if so, triggering is originally
Demapping instruction of the ground address list synchronization to wechat enterprise number address list;
Alternatively, clocked flip local address book is synchronized to the demapping instruction of wechat enterprise number address list, it herein can be in sky
Not busy time triggered smooth can specifically be transmitted by programmer oneself specified trigger conditions, so as to occupied few in network
When trigger.
In step d, wechat enterprise number background program receives instruction, establishes data mapping tasks, judges that mapping tasks are
It is no to be successfully established, if success, enters step e, if failure, re-establishes or exits the program.
In step f, full dose member data current in wechat enterprise number address list is obtained, is synchronized initiating Asynchronous Incremental
Backup is completed before task to be packaged, and full dose member data is transferred to backup groupings.
In step h, wechat enterprise number handles the asynchronous task notice of incremental data mapping, and adjusts back handling result, connects
After receiving handling result, the mapping tasks of communication directory structures are initiated.
In step i, local address book structured data is obtained, the address list structured data of full dose is generated, it is local raw herein
At local address book structured data be csv formatted files.
In step j, the asynchronous task that full dose communication directory structures covers is initiated to wechat enterprise number, local address book knot
On structure complete map to wechat enterprise number.
In step k, before wechat enterprise number establishes address list member data mapping tasks, address list structure mapping is obtained
The readjustment of task is as a result, judge whether that successfully local address book structured data is mapped on wechat enterprise number, if success,
Wechat enterprise number establishes address list member data mapping tasks, if failure, return to step h;Meanwhile the number of failure is recorded,
And default sample times N 1 then exits the program when the number of failure is more than sample times N 1.
In step l, all member datas of local address book and the affiliated local grouping information of each member are obtained,
Generate the required file of Asynchronous Incremental synchronous task;Wherein, the local address book member data locally generated is csv format texts
Part.
In step m, wechat enterprise number initiate increment synchronization member data asynchronous task, local address book it is all at
Member's data are mapped in corresponding address list packet configuration;
In step n, before wechat enterprise number establishes backup groupings membership synchronization's task, obtains address list member data and reflect
The readjustment of task is penetrated as a result, judging whether that successfully local address book member data is mapped on wechat enterprise number, if success,
Backup groupings membership synchronization's task is established in wechat enterprise number, if failure, return to step l;In step n, time of failure is recorded
Number, and default sample times N 2 then exit the program when the number of failure is more than sample times N 2;
In step o, wechat enterprise number interface is called to obtain all member datas under " backup " grouping, and be iterated
Cleaning;
It modifies to address list in local, self-defined communication directory structures, and according to this communication directory structures person of being written to
Data, the demapping instruction that local triggering is synchronized to wechat public platform first establish backup groupings due to the characteristic of wechat public platform,
It is packaged the member data of full dose in current wechat enterprise number address list, and the member data of full dose is transferred to backup groupings, is protected
Card can modify to the communication directory structures in wechat enterprise number, can remove in wechat enterprise number and be not belonging to local address book
The grouping of structure eliminates the obstacle that will appear conflict in full dose overwrite procedure, local to reflect local address book structured data
It is mapped in wechat public platform;Local address book member data is mapped in wechat public platform again at this time, and according to address list
Structured data is grouped, and finally clears up the extra member data that local address book member data is not belonging in backup groupings;
The design is by local search and safeguards data speed faster, and performance is more preferable, has higher success rate;Simultaneously can ensure it is local with it is micro-
Believe that enterprise number both sides data are consistent, flexibility is more preferable, by local address book structural adjustment or self-defined to be applied to
On long-range wechat enterprise number address list.
The foregoing is merely the preferred embodiments of the present invention, and the present invention is not limited to the above embodiments, as long as with
Essentially identical means realize that the technical solution of the object of the invention belongs within protection scope of the present invention.