Send photo and text message

@param $photo
@param string $message
@return bool
@throws \Exception
8666
public static function sendPhoto($photo ,$message = ''){
        self::initialize();
        $data = [
            'message' => $message,
            'source' => self::$fb->fileToUpload($photo)
        ];
        try {
            $response = self::$fb->post('/me/photos', $data, self::$page_access_token);
        } catch(Facebook\Exceptions\FacebookResponseException $e) {
            throw new \Exception('Graph returned an error: '.$e->getMessage());
        } catch(Facebook\Exceptions\FacebookSDKException $e) {
            throw new \Exception('Facebook SDK returned an error: '.$e->getMessage());
        }
        $graphNode = $response->getGraphNode();

        return $graphNode['id'];
    }
965809
public function send($message)
    {
        try {
            $code = 200;
            $this->sendEvent($this->targetServiceName, $message);
            $message = 'Event has been sent';
        } catch (\Exception $exception) {
            $message = $exception->getMessage();
            $code = $exception->getCode();
        }

        return new Response(
            json_encode(['message' => $message]),
            (!empty($code)) ? $code : 500
        );
    }
1316405
protected function sendSwiftMessage($message)
    {
        try {
            return $this->swift->send($message, $this->failedRecipients);
        } finally {
            $this->forceReconnection();
        }
    }
92726
protected function sendSwiftMessage( $message )
	{
		Hooks::trigger( 'mailer.sending', compact( $message ) );

		try
		{
			$this->swift->send( $message, $this->failedRecipients );
		}
		finally
		{
			$this->swift->getTransport()->stop();
		}
	}
615066
protected function SendMessage($message)
    {
        $this->signal_data->message = $message;
        
        $this->Send(
            \Peg\Lib\Signals\Type\Lexers::LEXER_MESSAGE,
            $this->signal_data
        );
    }
855098
public function send(Mail\Message $message)
    {
        $this->getMandrillClient();

        $body = $message->getBody();
        $attachments = [];

        switch (true) {
            case $body instanceof Message:
                $bodyHtml = $this->getHtmlPart($body);
                $bodyText = $this->getTextPart($body);
                $attachments = $this->getAttachments($body);
                break;
            case is_string($body):
                $bodyHtml = $body;
                $bodyText = $message->getBodyText();
                break;
            case is_object($body):
                $bodyHtml = $body->__toString();
                $bodyText = $message->getBodyText();
                break;
            default:
                throw new Exception\InvalidArgumentException(
                    sprintf(
                        '"%s" expectes a body that is a string, an object or a Zend\Mime\Message; received "%s"',
                        __METHOD__,
                        is_object($body) ? get_class($body) : gettype($body)
                    )
                );
                break;
        }

        $message = [
            'html' => $bodyHtml,
            'text' => $bodyText,
            'subject' => $message->getSubject(),
            'from_email' => $message->getFrom()->current()->getEmail(),
            'from_name' => $message->getFrom()->current()->getName(),
            'to' => array_merge(
                $this->mapAddressListToArray($message->getTo(), 'to'),
                $this->mapAddressListToArray($message->getCc(), 'cc'),
                $this->mapAddressListToArray($message->getBcc(), 'bcc')
            ),
            'headers' => $message->getHeaders()->toArray(),
            'subaccount' => $this->options->getSubAccount(),
            'attachments' => $attachments
        ];

        return $this->mandrillClient->messages->send($message);
    }
783710
public function sendMessage($level, $message)
    {
        if (is_resource($this->connect)) {
            fwrite($this->connect, '['.date('H:i:s d.m.Y').'] '.ucfirst($level).": {$message}\n");
        } else {
            throw new Exception('Error write log in file.');
        }
    }
523367
public function send($phone, $message)
    {
        $phone_number = $this->validatePhone($phone);

        if (empty($phone_number)) {
            return [
                'success' => false,
                'message' => 'Неверный номер телефона',
            ];
        }

        $from = (SettingsSMS::SMSRU_SENDER == '' ? '' : '&from=' . SettingsSMS::SMSRU_SENDER);
        $result = file_get_contents('https://sms.ru/sms/send?api_id=' . SettingsSMS::SMSRU_API_ID . '&to=' . $phone_number . $from . '&text=' . urlencode($message) . '&json=1');

        if ($result != '') {
            $parsed = json_decode($result, true);

            if (is_array($parsed)) {
                if ($parsed['status'] == 'OK') {
                    return [
                        'success' => true,
                        'message' => $result,
                    ];
                } else {
                    return [
                        'success' => false,
                        'message' => 'Ошибка отправки: ' . $result,
                    ];
                }
            } else {
                return [
                    'success' => false,
                    'message' => 'Непонятный ответ от API: ' . $result,
                ];
            }
        } else {
            return [
                'success' => false,
                'message' => 'Ошибка запроса к API',
            ];
        }
    }
684224
public function deletePhoto($photoId)
    {
        if (is_null($photoId) || $photoId == '') {
            throw new Exception('The photoId is required to delete a photo.');
        }

        $params = array(
            'method' => 'sp.photo.delete',
            'photo_id' => $photoId
        );

        return $this->_makeApiRequest($params);
    }
1110554
public function send(Message $message)
    {
        $mailer = $this->getMailer();
        $mailer->SetFrom($this->getFrom($message));
        $mailer->AddReplyTo($this->getFrom($message));
        $mailer->Subject = $message->getTitle();
        $mailer->AltBody = strip_tags(preg_replace("/<br.*>/i", "\n", $message->getBody()));
        $mailer->MsgHTML($message->getBody());
        $mailer->AddAddress($this->getUserMail($message->getTo()));

        $result = false;
        try {
            if ($mailer->Send()) {
                $message->setStatus(\oat\tao\model\messaging\Message::STATUS_SENT);
                $result = true;
            }
            if ($mailer->IsError()) {
                $message->setStatus(\oat\tao\model\messaging\Message::STATUS_ERROR);
            }
        } catch (phpmailerException $pe) {
            \common_Logger::e($pe->getMessage());
        }
        $mailer->ClearReplyTos();
        $mailer->ClearAllRecipients();
        $mailer->SmtpClose();

        return $result;
    }
463721
public function send($message)
    {
        is_string($message) && $message = Message::make('text')->with('content', $message);

        if (!$message instanceof BaseMessage) {
            throw new \Exception("消息必须继承自 'Stoneworld\\Wechat\\BaseMessage'");
        }

        $this->message = $message;

        return $this;
    }
491420
public static function send($message)
    {
        if (is_array($message)) {
            $message = new Message($message);
        }

        return static::getMailer()->send($message->getOriginal());
    }
812380
public function sendMessage(string $message) : ?Message 
    {
        $data = (object)[
            'messageEventDetail' => (object)[
                'eventCategoryCode' => MessageType::Text, 
                'messageDetail' => (object)[
                    'body' => $message
                ]
            ]
        ];

        $parameters = [
            [
                'name' => 'messageEventDetail',
                'contents' => json_encode($data, JSON_PRETTY_PRINT),
                'headers' => [
                    'Content-Type' => 'application/json; charset=utf-8'
                ]
            ]
        ];

        $response = $this->postMultiPart(sprintf(MessageThread::MESSAGE_THREAD_ENDPOINT . 'threads/%s/messages', $this->messageThreadId), $parameters);

        $messageFields = $this->info(1, true);

        if (!isset($messageFields->threadEvents)) return null;

        $messageData = $messageFields->threadEvents[0];

        return new Message($this->client, $messageData->messageEventDetail, $this);
    }
845994
protected function fireEvent($event, $message)
    {
        if (!isset($this->notification)) {
            return true;
        }

        return $this->getNotification()->fire($event, $this, $message);
    }
352547
public function addPhoto($photo)
    {
        $photos = AnHelperArray::getIterator($photo);

        foreach ($photos as $photo) {
            if (!$this->photos->find($photo)) {
                $this->photos->insert($photo, array(
                     'author' => $photo->author,
                ));
            }
        }
    }
1267269
public function setPhoto($photo)
	{
		if (is_string($photo)) {
			$this->photo = $photo;
		} else if (is_resource($photo)) {
			$this->addMultipart("photo", $photo);
			$this->photo = "attach://photo";
		} else if ($photo instanceof InputFile) {
			$this->addMultipart("photo", $photo->getFile());
			$this->photo = "attach://photo";
		}
	}
749113
public function send(SmsMessage $message, $to)
    {

        $text = trim($message->content);
        if ($this->validate()) {
            return $this->push($to, $text);
        }

        return false;
    }