| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace Heanup\Library\Sms;
- use Heanup\App\Api\Config\Code;
- use Heanup\App\Api\Package\Database\Num;
- use Heanup\Library\Curl;
- use Heanup\Library\Redis;
- use PhpImap\Mailbox;
- use QL\QueryList;
- class GoogleVoice implements Sms
- {
- /**
- * @return string[]
- */
- public function getCountry(): array
- {
- return [];
- }
- /**
- * @param $link
- * @return array
- */
- public function getPhoneNums($link): array
- {
- return [];
- }
- public function getMessage($country, $phone_num): array
- {
- $mailbox = new Mailbox(
- '{mail.97admin.com:993/imap/ssl/novalidate-cert}INBOX', // IMAP server and mailbox folder
- "gv@a4sky.com", // Username for the before configured mailbox
- "6485882", // Password for the before configured username
- __DIR__, // Directory, where attachments will be saved (optional)
- 'UTF-8' // Server encoding (optional)
- );
- $mail_ids = $mailbox->searchMailbox('FROM txt.voice.google.com');
- $from_google=true;
- $cache=Redis::instance();
- $i=0;
- foreach ($mail_ids as $mail_id) {
- if ($i>=20){
- break;
- }else{
- $key="mails_gv:".$mail_id;
- $temp=$cache->get($key);
- if (!$temp) {
- $detail = $mailbox->getMail($mail_id);
- if ($from_google){
- $from_num=$detail->fromName;
- $txt = explode("\r\n", $detail->textPlain)[1];
- $date=$detail->date;
- }else{
- $from_num=str_replace("Message from ", "", $detail->subject);
- $txt=$detail->textPlain;
- $rwn=explode("\r\n", $detail->headersRaw);
- $date=explode(": ", $rwn[2])[1];
- }
- $temp=[
- 'from' =>$from_num,
- 'time' => date("Y-m-d H:i:s",strtotime($date)),
- 'message' => $txt
- ];
- $cache->set($key, $temp);
- }
- $mail_info[]=$temp;
- }
- $i++;
- }
- krsort($mail_info);
- return $mail_info;
- }
- }
|