"For developers", "Server scripts", "Functions description", "Users", "mExtractUserPhoto".

 

Exporting MyChat user profile photo to a file on the disk. The photo is saved in JPG format.

 

Syntax

function mExtractUserFoto(iUIN: integer; sPath, sFileName: string): integer;

 

Parameters and return values

Parameter

Type

Value

iUIN

integer

unique user identifier;

sPath

string

path on the disk, where you need to save the photo. The path must exist;

sFileName

string

name of the file for export (to the dot). For example, "myfile". The function adds the extension — ".jpg" at the end automatically.

 

Function result

0, if exporting done successfully;

-1, user with such UIN not found on the server;

-2, such user does not have the profile photo;

-3, exporting path is specified incorrectly or the folder does not exist;

-4, error saving file (no place on the disk, error writing on the secured disk, no rights to make entries, etc.).

 

Example

Exporting all user's photos into the server folder c:\temp\foto\

var
  sUsersList: string;
  iUIN: integer;
begin
  sUsersList := mGetUsersListByState(-2);
  
    while length(sUsersList) > 0 do begin
      iUIN := strtoint(Fetch(sUsersList, ','));
      mExtractUserPhoto(iUIN, 
                       'c:\temp\photo\', 
                       '(' + inttostr(iUIN) + ') ' + mGetUserAttribute(iUIN, 'DisplayName'));
    end;
end.

Script work result

[15:38:21] (Run "ExtractAllUserPhotos"): Script operation time: 695 ms

[15:38:21] (Run "ExtractAllUserPhotos"): Script done successfully.

 

See also

Fetch

IntToStr

mGetUserAttribute

mGetUsersListByState