// Declare an Apsara Stack Group class (which may include multiple groups). The SDK is an instance of the fetionsdk class.
Nullstudio. fetion_sdk.group.groupbase group = new nullstudio. fetion_sdk.group.groupbase (SDK );
// Obtain the list of all groups
List <personalgroup> pergrp = group. getpersonalgrouplist ();
// The following two codes are crucial. If no code is available, the group member list cannot be loaded (this is the result of my efforts to use. Net reflector)
Asyncbizoperation op = new asyncbizoperation (pergrp [0]);
SDK. accountmanager. currentuser. personalgroupmanager. getgroupmemberlist (pergrp [0], OP );
// Display members in the pergrp [0] Group
// Note: the execution of the above two lines of code takes some time. If the following code is followed, the MSG value may be blank;
// You can add the event pergrp [0]. memberloadstatuschanged
// Call the following code in the function called by the event
String MSG = string. empty;
Lock (pergrp [0]. members. syncobject)
{
Foreach (personalgroupmember member in pergrp [0]. Members)
{
MSG + = member. displayname + "/N ";
}
}
MessageBox. Show (MSG );
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/lxiongh/archive/2009/09/09/4536873.aspx
Fetionsdk. dll description by sysu_lxiongh
Preface:
This article was written based on fetionsdk. dll. The code in this article is the result of my study on fetionfx.exe in Feixin 2008 developed by China Mobile through reflector. fetionsdk. dll:
Http://sites.google.com/site/allwealthshare/software/FetionSDK.dll.rar? Attredirects = 0
The mobile Apsara client is developed in C #, so we are using fetionsdk. dll should also be developed in C # language when developing its own Apsara client (I don't know if it can be developed in other languages, such as C ++ ). one thing to note is that this fetionsdk. DLL is a bit capable of reverse encoding, and some bugs are inevitable. for example, if a friend is not in a group, he or she cannot send a text message or load his or her information. (solution: log on to the group with a mobile flying mail and add it to the group ).
(The way to contact: sysu _ short number: 611449, QQ: 464050924)
Functions:
1. log on to Apsara stack, log off Apsara stack, and set the Apsara stack logon status.
2. Load the friends list.
3. Get the group of friends list.
4. Load the fetion group member list.
5. Attach a friend image (portrait ).
6. Attach any flying signal image (portrait ).
7. send instant messages and text messages.
8. Receive Feixin friends.
9. Add fetion friends.
(There will be more ...)
If you get some funtions different and you can realize it.
I will be very happy if you can share with me through
QQ, email or other contact way.
Specific implementation:
Add the following namespaces to references:
Using nullstudio. fetion_sdk;
Using imps. core;
(Of course there may be other namespaces, which will not be written here)
Several important events (these should be within the global scope)
SDK. sdk_receivemessage + = new fetionsdk. sdk_receivemessageeventhandler (sdk_sdk_receivemessage );
SDK. sdk_usersatuschange + = new fetionsdk. sdk_usersatuschangedeventhandler (sdk_sdk_usersatuschange );
SDK. sdk_error + = new fetionsdk. sdk_erroreventhandler (sdk_sdk_error );
Declare a global variable: fetionsdk SDK (this is a general class of Apsara control, acting on the entire program)
Function 1 (log on to Apsara stack, log off Apsara stack, and set the Apsara stack logon status ):
// Fill mobile phone number and password.
SDK. accountmanager. filluseridandpassword (string ID, string password, bool autologinorout)
// Automatically determine whether to log on or log off
SDK. accountmanager. loginorout ();
// Set the logon status of Apsara stack, which is set to online
(Prerequisite: Apsara Stack has logged on. You can call this method when the logon status of Apsara stack is logon)
SDK. accountmanager. currentuser. presence. asyncchangemainpresence (imps. Common. mainpresence. Online, imps. Common. mainpresence. Online. tostring ());
Function 2 (load friend list ):
SDK. contactcontrol. getallcontactlist (); // returns a list of contact types <imps. Core. Contact>
Function 3 (attach a friend group ):
List <contactgroup> cotactgroups = SDK. contactcontrol. getcontactgroup ();
// You can load the friends list of this group in contactgroup.
List <contact> contacts = contactgroup. Contacts. listcontacts.
Function 4 (load group member list ):
Groupbase = new groupbase (SDK );
List <personalgroup> personalgroups = groupbase. getpersonalgrouplist ();
// The following code is very important. If it is missing, there is only some basic information in personalgroups, and the member information is not.
Foreach (personalgroup in personalgroups)
{
Asyncbizoperation op = new asyncbizoperation ();
Lock (OP)
{
SDK. accountmanager. currentuser. personalgroupmanager. getgroupmemberlist (group, OP );
}
}
Function 5, 6 (image loading ):
First, you must obtain a valid contact instance.
Add the contact. contactinfo. propertieschanged event.
Finally, download the image in the Event code.
The basic code is as follows:
Iicuri uri = URI. creaturi (string inclueno );
Contact contact = SDK. accountmanager. currentuser. contactlist. findfindcontactbymsisdnex (URI. inclueno );
If (contact = NULL)
{
Asyncbizoperation op = new asyncbizoperation ();
Contact = SDK. accountmanager. currentuser. contactlist. findorcreatecontact (URI. Raw, OP );
}
// Add an event
Contact. personalinfo. propertieschanged + = new eventhandler <propertieschangedeventargs> (personalinfo_propertieschanged );
Void personalinfo_propertieschanged (Object sender, propertieschangedeventargs E)
{
// If the returned value is true, the image download is complete.
If (! E. containsanyofproperties (New String [] {"nickname", "provision", "portrait "}))
{
Picturebox1.image = (contactinfo) sender). portrait;
}
}
Function 7 (send messages)
SDK. contactcontrol. sendsms. sendsms (friendphone, MSG); // send a text message
SDK. contactcontrol. sendim. sendim (friendphone, MSG); // instant messaging
(Note: Use contact. presence. mainpresence to determine the user status in the attribute value, for example:
Imps. Common. mainpresence. offlinelogin,
Imps. Common. mainpresence. offline );
Function 8 (receive friend Information)
Before receiving information, add the event SDK. sdk_receivemessage.
Then receive messages in the event
Function 9 (add fetion friends)
// Declare Variables
Bool isbymobileno = false; // whether to add a letter to a mobile phone number
String id = string. Empty; // userid
String domain = string. Empty; // domain
Nullable <int> targetgroupid = NULL; // to which group (each contactgroup has an ID attribute)
String localname = string. Empty; // local remarks
Contactlist. addbuddyextradata extradata = new contactlist. addbuddyextradata ();
Bool sendrequestagain = false;
Bool copywhenexist = false;
Nullable <bool> invite = NULL;
Asyncbizoperation op = new asyncbizoperation ();
// Assign a value
Iicuri uri = iicuri. createteluri (friendno );
Id = URI. inclueno;
Isbymobileno = true;
Domain = "fetion ";
Targetgroupid = targetid;
Localname = "// local remark name"
Extradata = new contactlist. addbuddyextradata ();
Extradata. whoami = "// Who am I ?"
Sendrequestagain = true;
Copywhenexist = false;
Invite = NULL;
// Execute to add a friend
Op. impserror + = new eventhandler <impserroreventargs> (op_impserror );
Op. successed + = new eventhandler (op_successed );
SDK. accountmanager. currentuser. contactlist. asyncaddbuddy (isbymobileno, ID, domain, targetgroupid, localname, extradata, sendrequestagain, copywhenexist, invite, OP );
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/lxiongh/archive/2009/09/23/4584642.aspx
Since fetion was originally made using C #, many sections can be decompiled. From the perspective of robot development, the simplest entry is fetionsdk, a public project last year, which can be found on Google's code website. However, because it implements the API of Feixin DLL. Therefore, there are many bugs. For example, a friend's online status notification cannot be obtained. In this case, you can copy the DLL of the new version of Apsara to the original project, compile it, and see several unimplemented interfaces. Then you can implement them in the project. In theory, it can be upgraded following the upgrade of the Apsara stack version. Currently, the following events can be used in the Feixin robot project: SDK. sdk_receivemessage + = sdk_sdk_receivemessage; SDK. sdk_usersatuschange + = sdk_sdk_usersatuschange; SDK. sdk_error + = sdk_sdk_error; SDK. accountmanager. currentuser. contactlist. contactschanged + = new eventhandler <contactschangedeventargs> (contactlist_contactschanged ); SDK. accountmanager. currentuser. contactlist. addbuddyrequest + = new eventhandler <addbuddyapplicationeventargs> (contactlist_addbuddyrequest ); SDK. accountmanager. currentuser. contactlist. contacttypechanged + = new eventhandler <contacttypechangedeventargs> (contactlist_contacttypechanged );
Some other methods have not been triggered or used for the moment (invite friends actively: // SDK. accountmanager. currentuser. contactlist. addmobilebuddyreply + = new eventhandler (contactlist_addmobilebuddyreply ); // SDK. accountmanager. currentuser. contactlist. addbuddyresult + = new eventhandler <addbuddyresulteventargs> (contactlist_addbuddyresult ); // SDK. accountmanager. currentuser. personalgroupmanager. invitejoingroup + = new eventhandler <invitejoingroupeventargs> (personalgroupmanager_invitejoingroup ); // SDK. accountmanager. currentuser. contactlist. Changed + = new eventhandler <contactlisteventargs> (contactlist_changed );
If you can see the above content, do not ask for code. It is easy to implement the interface method by yourself. Leave the content empty. In addition, the flying mail robot can send files. Interested people can study the conversationmanager. sendfile method. Decompiled fetionfx.exe to find the sendfile method of the officially implemented code (in conversationwindows. CS) file. The Code is as follows: Private void sendfile (bool tomobile, string filepath) { Try { If (! Envhelper. dynamicgifctlregistered) { Base. uniiedmessagebox. showinfo (this, "You cannot send shared files now. Please contact the system administrator! "); } Else { If (this. currentconversation = NULL) | (this. currentconversation. currentdialog = NULL )) { This. initconversation (); } This. checkconversaiton (); If (this. currentconversation. currentdialog. contents. count = 0) & this. currentconversation. currentdialog. ismulticonversation) & (this. currentconversation. currentdialog. participant. count = 1 )) { Imps. Client. Core. Contact contact = This. currentconversation. currentdialog. Fig [0]. contact; This. currentconversation. Close (); Thread. Sleep (50 ); This. currentconversation = base. currentuser. conversationmanager. openconversation (contact ); This. sendfile (tomobile, filepath ); } Else if (this. checkbeforeupload ()) { Uploademedicontent item = This. createuploademedicontent (tomobile, filepath ); If (item! = NULL) & this. checkbeforeupload ()) { Asyncbizoperation operation = new asyncbizoperation (); Item. bizoperation = operation; Operation. impserror + = new eventhandler <impserroreventargs> (this. op_impserror ); This. currentconversation. currentdialog. Specify contents. Add (item, true ); Item. sendfile (); } } } } Catch (exception) { Clientlogger. writegeneral ("failed to send file", exception. tostring ()); } } Modify the relevant part of the Apsara stack SDK based on this idea. |
Attach the image portrait (it belongs to contact. contactinfo. Portrait)
First, you must obtain a valid contact instance.
Add the contact. contactinfo. propertieschanged event.
Finally, download the image in the Event code.
The basic code is as follows:
Iicuri uri = URI. creaturi (string inclueno );
Contact contact = SDK. accountmanager. currentuser. contactlist. findfindcontactbymsisdnex (URI. inclueno );
If (contact = NULL)
{
Asyncbizoperation op = new asyncbizoperation ();
Contact = SDK. accountmanager. currentuser. contactlist. findorcreatecontact (URI. Raw, OP );
}
// Add an event
Contact. personalinfo. propertieschanged + = new eventhandler <propertieschangedeventargs> (personalinfo_propertieschanged );
Void personalinfo_propertieschanged (Object sender, propertieschangedeventargs E)
{
// Here it should be a loop. If the returned value is true, the image download is complete.
While (! E. containsanyofproperties (New String [] {"nickname", "provision", "portrait "}))
{}
Picturebox1.image = (contactinfo) sender). portrait;
}
// Some code related to fetionsdk. dll Feixin development has been sent in the last few days, which are messy and not organically organized.
// These are some basic modules. If you have time, I will organize all the code and send it to my blog. Please stay tuned!
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/lxiongh/archive/2009/09/15/4556614.aspx