Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ultramsg authored Aug 12, 2023
1 parent cc93fc4 commit a1234da
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 23 deletions.
57 changes: 37 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Supported extensions ( jpg , jpeg , gif , png , svg , webp , bmp ) .

Max file size : 16MB .

Max Base64 length : 2,000,000
Max Base64 length : 10,000,000

* **$nocache** : default false

Expand All @@ -85,22 +85,50 @@ $referenceId="SDK";
$nocache=false;
$api=$client->sendImageMessage($to,$image,$caption,$priority,$referenceId,$nocache);
print_r($api);

```
## Send Sticker
* **$sticker** : HTTP link image or base64-encoded file

Supported extensions ( jpg , jpeg , gif , png , svg , webp , bmp ) .

Max file size : 16MB .

Max Base64 length : 10,000,000

* **$nocache** : default false

false : use a previously uploaded file instead of uploading it with each request

true : uploading it each request

```php
$to="put_your_mobile_number_here";
$sticker="https://file-example.s3-accelerate.amazonaws.com/images/test.jpg";
$priority=10;
$referenceId="SDK";
$nocache=false;
$api=$client->sendStickerMessage($to,$sticker,$priority,$referenceId,$nocache);
print_r($api);
```

## Send Document
* **$filename** : File name, for example 1.jpg or Hello.pdf
* **$caption** : Document Caption, UTF-8 or UTF-16 string with emoji .
* **$document** : HTTP link file or base64-encoded file

Supported most extensions like ( zip , xlsx , csv , txt , pptx , docx ....etc ) .

Max file size : 100MB .

Max Base64 length : 2,000,000
Max Base64 length : 10,000,000

```php
$to="put_your_mobile_number_here";
$filename="image Caption";
$filename="File name";
$caption="Document Caption";
$document="https://file-example.s3-accelerate.amazonaws.com/documents/cv.pdf";
$api=$client->sendDocumentMessage($to,$filename,$document);
$api=$client->sendDocumentMessage($to,$filename,$document,$caption);
print_r($api);
```

Expand All @@ -111,7 +139,7 @@ Supported extensions ( mp3 , aac , ogg ) .

Max file size : 16MB .

Max Base64 length : 2,000,000
Max Base64 length : 10,000,000

```php
$to="put_your_mobile_number_here";
Expand All @@ -124,7 +152,7 @@ print_r($api);

Max file size : 16MB .

Max Base64 length : 2,000,000
Max Base64 length : 10,000,000

```php
$to="put_your_mobile_number_here";
Expand All @@ -140,7 +168,7 @@ Supported extensions ( mp4 , 3gp , mov ) .

Max file size : 16MB .

Max Base64 length : 2,000,000
Max Base64 length : 10,000,000

```php
$to="put_your_mobile_number_here";
Expand Down Expand Up @@ -297,18 +325,7 @@ print_r($api);
$api=$client->getInstanceQrCode();
print_r($api);
```
## Get Instance Screenshot

```php
header('Content-Type: image/png');
$api=$client->getInstanceScreenshot();
print_r($api);
```
or base64
```php
$api=$client->getInstanceScreenshot("base64");
print_r($api);
```

## Get Instance Info
Get connected phone informations : number , name , image etc..
```php
Expand Down Expand Up @@ -456,4 +473,4 @@ print_r($api);


# Support
Use **Issues** to contact me
Use **Issues** to contact me
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"url": "https://github.com/ultramsg/whatsapp-php-sdk"
}
],
"version": "2.0.7",
"version": "2.0.8",
"license": "MIT",
"authors": [
{
Expand Down
8 changes: 6 additions & 2 deletions ultramsg.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ public function sendImageMessage($to,$image,$caption="",$priority=10,$referenceI
$params =array("to"=>$to,"caption"=>$caption,"image"=>$image,"priority"=>$priority,"referenceId"=>$referenceId,"nocache"=>$nocache);
return $this->sendRequest("POST","messages/image",$params );
}
public function sendStickerMessage($to,$sticker,$priority=10,$referenceId="",$nocache=false){
$params =array("to"=>$to,"sticker"=>$sticker,"priority"=>$priority,"referenceId"=>$referenceId,"nocache"=>$nocache);
return $this->sendRequest("POST","messages/sticker",$params );
}

public function sendDocumentMessage($to,$filename,$document,$priority=10,$referenceId="",$nocache=false){
$params =array("to"=>$to,"filename"=>$filename,"document"=>$document,"priority"=>$priority,"referenceId"=>$referenceId,"nocache"=>$nocache);
public function sendDocumentMessage($to,$filename,$document,$caption="",$priority=10,$referenceId="",$nocache=false){
$params =array("to"=>$to,"filename"=>$filename,"document"=>$document,"caption"=>$caption,"priority"=>$priority,"referenceId"=>$referenceId,"nocache"=>$nocache);
return $this->sendRequest("POST","messages/document",$params );
}

Expand Down

0 comments on commit a1234da

Please sign in to comment.