Profile
in package
WhatsApp PHP Profile entity.
Tags
Table of Contents
Properties
- $contactName : string|null
- Profile saved contact name, if any.
- $isBlocked : bool
- Is user blocked?
- $isBusiness : bool
- Is user a business account?
- $isEnterprise : bool
- Is user an enterprise account?
- $isMe : bool
- Is user myself?
- $isSaved : bool
- Is user saved in my contacts?
- $isValid : bool
- Is a valid WA user?
- $name : string
- Profile public name.
- $number : string
- Profile number.
- $profilePicture : string|null
- Profile picture URL, if available.
- $shortname : string|null
- Profile short name, if any.
- $status : string|null
- User status, if available.
Methods
- __construct() : mixed
- Create Profile entity.
- downloadProfilePicture() : string
- Downloads the profile picture, if available, to the local disk.
- getMessages() : array<string|int, Message>
- Gets the messages from this profile.
- searchMessages() : array<string|int, Message>
- Searches for a message in this profile.
- sendLocation() : bool
- Sends a location pin to this profile.
- sendMedia() : bool
- Sends a media message to this profile.
- sendMessage() : bool
- Sends a text message to this profile.
- sendSticker() : bool
- Sends a sticker to this profile.
- sendVoice() : bool
- Sends a voice message to this profile.
Properties
$contactName
Profile saved contact name, if any.
public
string|null
$contactName
$isBlocked
Is user blocked?
public
bool
$isBlocked
$isBusiness
Is user a business account?
public
bool
$isBusiness
$isEnterprise
Is user an enterprise account?
public
bool
$isEnterprise
$isMe
Is user myself?
public
bool
$isMe
$isSaved
Is user saved in my contacts?
public
bool
$isSaved
$isValid
Is a valid WA user?
public
bool
$isValid
$name
Profile public name.
public
string
$name
$number
Profile number.
public
string
$number
$profilePicture
Profile picture URL, if available.
public
string|null
$profilePicture
$shortname
Profile short name, if any.
public
string|null
$shortname
$status
User status, if available.
public
string|null
$status
Methods
__construct()
Create Profile entity.
public
__construct([array<string|int, mixed> $data = [] ]) : mixed
Parameters
- $data : array<string|int, mixed> = []
-
(Optional) Associative array of data to populate.
downloadProfilePicture()
Downloads the profile picture, if available, to the local disk.
public
downloadProfilePicture(string $path[, string $filename = null ]) : string
Parameters
- $path : string
-
Location folder in where to salve the file.
- $filename : string = null
-
(Optional) Custom filename to set, leave blank to use the original filename.
Tags
Return values
string —Returns the downloaded file location.
getMessages()
Gets the messages from this profile.
public
getMessages([int|null $limit = null ]) : array<string|int, Message>
Parameters
- $limit : int|null = null
-
(Optional) Maximum number of messages to fetch. Leave blank to get as many as possible.
Tags
Return values
array<string|int, Message> —Returns a list of messages.
searchMessages()
Searches for a message in this profile.
public
searchMessages(string $query[, int|null $limit = null ][, int|null $page = null ]) : array<string|int, Message>
Parameters
- $query : string
-
Query string to search.
- $limit : int|null = null
-
(Optional) Maximum number of messages to fetch.
- $page : int|null = null
-
(Optional) Results page number.
Tags
Return values
array<string|int, Message> —Returns a list of messages.
sendLocation()
Sends a location pin to this profile.
public
sendLocation(int $latitude, int $longitude[, string|null $address = null ][, string|null $url = null ]) : bool
Parameters
- $latitude : int
-
Latitude coordinates.
- $longitude : int
-
Longitude coordinates.
- $address : string|null = null
-
(Optional) Address name to include in the message.
- $url : string|null = null
-
(Optional) URL to include in the message.
Tags
Return values
bool —Returns true on success, false on failure.
sendMedia()
Sends a media message to this profile.
public
sendMedia(string $file[, string|null $message = null ][, bool $viewOnce = false ][, bool $asDocument = false ][, bool $asVoice = false ][, bool $asGif = false ][, bool $asSticker = false ]) : bool
Parameters
- $file : string
-
File location path or remote URL.
- $message : string|null = null
-
(Optional) Caption to send with the media.
- $viewOnce : bool = false
-
(Optional) Send the media as view once.
- $asDocument : bool = false
-
(Optional) Send the media as a document.
- $asVoice : bool = false
-
(Optional) Send audio media as a voice.
- $asGif : bool = false
-
(Optional) Send video media as a GIF.
- $asSticker : bool = false
-
(Optional) Send image media as a sticker.
Tags
Return values
bool —Returns true on success, false on failure.
sendMessage()
Sends a text message to this profile.
public
sendMessage(string $message) : bool
Parameters
- $message : string
-
Message body.
Tags
Return values
bool —Returns true on success, false on failure.
sendSticker()
Sends a sticker to this profile.
public
sendSticker(string $file) : bool
Parameters
- $file : string
-
Sticker image file location path or remote URL.
Tags
Return values
bool —Returns true on success, false on failure.
sendVoice()
Sends a voice message to this profile.
public
sendVoice(string $file[, bool $viewOnce = false ]) : bool
Parameters
- $file : string
-
Audio file location path or remote URL.
- $viewOnce : bool = false
-
(Optional) Send the audio as view once.
Tags
Return values
bool —Returns true on success, false on failure.