-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0a27787
Showing
7 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Package For 4jawaly Sms For Laravel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "mfrouh/4jawaly", | ||
"description": "Package For 4jawaly Sms For Laravel", | ||
"type": "library", | ||
"license": "MIT", | ||
"autoload": { | ||
"psr-4": { | ||
"Mfrouh\\Sms4jawaly\\": "src/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "mfrouh", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"MFrouh\\Sms4jawaly\\Providers\\Sms4JawalyServiceProvider" | ||
] | ||
}, | ||
"aliases": { | ||
"Sms4jawaly": "MFrouh\\Sms4jawaly\\Facades\\Sms4jawaly" | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"require": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace MFrouh\Sms4jawaly; | ||
|
||
use Illuminate\Support\Facades\Http; | ||
use Exception; | ||
|
||
class BaseClass | ||
{ | ||
const Base_Url = 'https://4jawaly.net/api'; | ||
|
||
public function getBalance() | ||
{ | ||
try { | ||
$data = [ | ||
'username' => config('sms4jawaly.username'), | ||
'password' => config('sms4jawaly.password'), | ||
'return' => 'json' | ||
]; | ||
|
||
$response = Http::get(self::Base_Url . '/getbalance.php', $data); | ||
|
||
return ['status' => true, 'response' => $response->currentuserpoints, 'message' => $response->MessageIs]; | ||
} catch (Exception $error) { | ||
return ['status' => false, 'response' => $error, 'message' => 'error']; | ||
} | ||
} | ||
|
||
public function sendSms($message, $phoneNumber) | ||
{ | ||
try { | ||
$data = [ | ||
'username' => config('sms4jawaly.username'), | ||
'password' => config('sms4jawaly.password'), | ||
"message" => urlencode($message), | ||
"numbers" => $this->convertArabicNumbers(ltrim($phoneNumber, '0')), | ||
"sender" => config('sms4jawaly.sender_name'), | ||
"unicode" => 'e', | ||
'return' => 'json' | ||
]; | ||
|
||
$response = Http::get(self::Base_Url . '/sendsms.php', $data); | ||
|
||
return $response; | ||
} catch (Exception $error) { | ||
return $error; | ||
} | ||
} | ||
|
||
private function convertArabicNumbers($number) | ||
{ | ||
$arabic = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩']; | ||
|
||
$english = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | ||
|
||
return str_replace($arabic, $english, $number); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace MFrouh\Sms4jawaly\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
class Sms4jawaly extends Facade | ||
{ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return 'Sms4jawaly'; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace MFrouh\Sms4jawaly\Sms4JawalyServiceProvider; | ||
|
||
use MFrouh\Sms4jawaly\BaseClass; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class Sms4JawalyServiceProvider extends ServiceProvider | ||
{ | ||
|
||
/** | ||
* Register the service provider. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->bind('Sms4jawaly', function ($app) { | ||
return new BaseClass(); | ||
}); | ||
} | ||
|
||
public function boot() | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return [ | ||
'username' => env('4JAWALY_USERNAME'), | ||
'password' => env('4JAWALY_PASSWORD'), | ||
'sender_name' => env('4JAWALY_SENDER_NAME') | ||
]; |