Skip to content

Commit

Permalink
Added support for self-signed certificates
Browse files Browse the repository at this point in the history
Upload your certificate using the certificate parameter in the
setWebhook method.
  • Loading branch information
mgp25 committed Aug 29, 2015
1 parent 6be39df commit 6ae305d
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/Telegram.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,23 @@ public function getUserProfilePhotos($user_id, $offset = null, $limit = null)
/**
* Set a Webhook to receive incoming updates via an outgoing webhook.
*
* @param string $url HTTPS url to send updates to.
* @param string $url HTTPS url to send updates to. Use an empty string to remove webhook integration
* @param InputFile $cerificate Upload your public key certificate so that the root certificate in use can be checked
*
* @return Array
*
*/
public function setWebhook($url)
public function setWebhook($url, $certificate = null)
{
if (filter_var($url, FILTER_VALIDATE_URL) === false)
throw new TelegramException('Invalid URL provided');

if (parse_url($url, PHP_URL_SCHEME) !== 'https')
throw new TelegramException('Invalid URL, it should be a HTTPS url.');

return $this->sendRequest('setWebhook', $url);
$params = compact('url', 'certificate');

return $this->sendRequest('setWebhook', $params);
}

/**
Expand All @@ -329,17 +332,6 @@ public function getWebhookUpdates()
return $body;
}

/**
* Removes the outgoing webhook.
*
* @return Array
*/
public function removeWebhook()
{
$url = '';
return $this->sendRequest('setWebhook', compact('url'));
}

/**
* Builds a custom keyboard markup.
*
Expand Down

0 comments on commit 6ae305d

Please sign in to comment.