Sends message to the Twitter.
https://dev.twitter.com/rest/reference/post/statuses/update
@param  string|array  $mediaPath  path to local media file to be uploaded
@throws Exception
498006
public function send(string $message, $mediaPath = null, array $options = []): stdClass
	{
		$mediaIds = [];
		foreach ((array) $mediaPath as $item) {
			$res = $this->request(
				'https://upload.twitter.com/1.1/media/upload.json',
				'POST',
				[],
				['media' => $item]
			);
			$mediaIds[] = $res->media_id_string;
		}
		return $this->request(
			'statuses/update',
			'POST',
			$options + ['status' => $message, 'media_ids' => implode(',', $mediaIds) ?: null]
		);
	}
76448
private function uploadMediaChunked($path, $parameters)
    {
        // Init
        $init = $this->http('POST', self::UPLOAD_HOST, $path, [
            'command' => 'INIT',
            'media_type' => $parameters['media_type'],
            'total_bytes' => filesize($parameters['media'])
        ]);
        // Append
        $segment_index = 0;
        $media = fopen($parameters['media'], 'rb');
        while (!feof($media))
        {
            $this->http('POST', self::UPLOAD_HOST, 'media/upload', [
                'command' => 'APPEND',
                'media_id' => $init->media_id_string,
                'segment_index' => $segment_index++,
                'media_data' => base64_encode(fread($media, self::UPLOAD_CHUNK))
            ]);
        }
        fclose($media);
        // Finalize
        $finalize = $this->http('POST', self::UPLOAD_HOST, 'media/upload', [
            'command' => 'FINALIZE',
            'media_id' => $init->media_id_string
        ]);
        return $finalize;
    }
643351
public function post($path, $params = []){
        $json = json_encode($params);
        
        return $this->_call('POST', $path, $json);
    }
1343318
public function write( $path, $content )
	{
		try {
			$this->fs->put( $path, $content );
		} catch( \Exception $e ) {
			throw new Exception( $e->getMessage(), 0, $e );
		}
	}
916466
protected function sendRequest($endpoint, $params, $multipart = false)
    {
        if (empty($this->token))
        {
            throw CouldNotSendNotification::telegramBotTokenNotProvided('You must provide your telegram bot token to make any API requests.');
        }

        $endPointUrl = 'https://api.telegram.org/bot'.$this->token.'/'.$endpoint;

        try {
            if($multipart)
                $post_name = 'multipart';
            else
                $post_name = 'form_params';

            return $this->httpClient()->post($endPointUrl, [
                $post_name => $params,
            ]);

        } catch (ClientException $exception) {
            throw CouldNotSendNotification::telegramRespondedWithAnError($exception);
        } catch (\Exception $exception) {
            throw CouldNotSendNotification::couldNotCommunicateWithTelegram($exception);
        }
    }
659915
private void sendJGroupsMessage(UpdateOpteration operation, String path,
      String auth) throws Exception {
    if(!this.isAuth(auth)) {
      throw new Exception("Unauthorized!");
    }
    log.trace("Sending jGroups message with operation {} and path {}", operation, path);
    ApiEndpointAccessRequest messageBody = new ApiEndpointAccessRequest();
    messageBody.setEndpoint(path);
    messageBody.setOperation(operation);
    Message<ApiEndpointAccessRequest> msg = new Message<ApiEndpointAccessRequest>(ProtocolMessage.API_ENDPOINT_ACCESS, messageBody);
    log.trace("Sending jgroups message: "+msg);
    sender.sendMessage(msg, null);
  }
244976
public function setFile($filePath = '.gitignore')
    {
        $this->fileContent = array();
        $this->afterLine = null;
        $this->filePath = $filePath;
        $this->checkPermissions();
        $this->parse();
    }
334395
public function setLogPath($path){
        if (!file_exists($path)){
            touch($path);
        }

        if (file_exists($path) && is_readable($path)){
            $this->logpath = $path;
        } else {
            throw new Exception("Log file does not exist or cannot be read! ($path)");
        }
        
    }
604581
public function addMaterial($mediaPath, $type, $data = [])
    {
        $result = $this->httpPost(self::WECHAT_MATERIAL_ADD_PREFIX, array_merge($data, [
            'media' => $this->uploadFile($mediaPath)
        ]), [
            'access_token' => $this->getAccessToken(),
            'type' => $type
        ]);
        return isset($result['media_id']) ? $result : false;
    }
1039481
private function uploadMediaNotChunked($path, $parameters)
    {
        $file = file_get_contents($parameters['media']);
        $base = base64_encode($file);
        $parameters['media'] = $base;
        return $this->http('POST', self::UPLOAD_HOST, $path, $parameters);
    }
1098144
public function setLocalPath($localPath)
    {
        if (!file_exists($localPath)) {
            throw new InvalidArgumentException(sprintf('File %s does not exist', $localPath));
        }

        $this->localPath = $localPath;
    }
7937
protected function uploadTemp($filePath, $type)
    {
        $url = sprintf(self::MEDIA_TEMP_UPLOAD_URL, $this->getAccessTokenString(), $type);
        $client = $this->getHttpClient();
        $client->setUrl($url);
        $client->setMethod(Client::METHOD_UPLOAD);

        $basename = basename($filePath);

        $client->setPostDataArray([ 'media'          => curl_file_create($filePath),
                                    'filename'      => $basename,
                                    'filelength'    => filesize($filePath),
                                    'content-type'  => $this->getUpLoadContentType($type),
                                    'hack'          => '',
                                    ]);
        if (!$client->exec()) {
            throw new Exception("call send custom service message fail");
        }

        $result = json_decode($client->getResponse(), true);

        if (isset($result['errcode'])) {
            throw new Exception("error response for upload Temp info " . $result['errcode'] . ' ' . $result['errmsg']);
        }

        return $result;
    }
1206799
public function setSupportedMediaTypes(array $mediaTypes)
    {
        foreach ($mediaTypes as $mediaType => $converterClass) {
            if (!is_string($mediaType)) {
                throw new Exception('Media type must be a string.');
            }

            if (!is_string($converterClass)) {
                throw new Exception('Converter class name must be a string.');
            }
        }

        $this->supportedMediaTypes = $mediaTypes;
    }
1151899
private function replaceDummyInFile($filePath)
    {
        $fileSource = File::get($filePath);
        $fileContent = str_replace(array_keys($this->dummyReplacements), array_values($this->dummyReplacements), $fileSource);
        $writeFile = File::put($filePath, $fileContent);
        if ($writeFile === false) {
            throw new \Exception("Error writing to file " . $filePath);
        }
    }
984063
public function moveTo($targetPath)
    {
        if ($this->moved) {
            throw new RuntimeException('Uploaded file already moved');
        }

        if (! is_writable(dirname($targetPath))) {
            throw new InvalidArgumentException('Upload target path is not writable');
        }

        if (! @rename($this->file, $targetPath)) {
            throw new RuntimeException(
                sprintf('Error moving uploaded file %1s to %2s', $this->name, $targetPath)
            );
        }

        $this->moved = true;
    }
148085
public function addPath($path)
    {
        if (!is_string($path)) {
            throw new Exception\InvalidArgumentException(sprintf(
                'Invalid path provided; must be a string, received %s',
                gettype($path)
            ));
        }

        $this->paths[] = $this->normalizePath($path);
    }
907966
public static function send($filePath, $remoteFileSystem)
    {
        return (new Client())->put($remoteFileSystem, ['body' => fopen($filePath, self::READ_BINARY)])
            ->getStatusCode() == HttpHelper::STATUS_OK;
    }