Exemple #1
0
function send($content)
{
    global $app;
    $http = new \HTTP\HTTPRequest($app->config->slack->incoming_webhook);
    $http->setMethod('POST');
    $http->setRequestBody(json_encode(array('channel' => '#' . $app->config->slack->announce_channel, 'text' => $content)));
    try {
        $http->send();
        echo $content . "\n";
    } catch (Exception $e) {
    }
}
Exemple #2
0
 function __construct($key, $sheetidx = 0)
 {
     $gsheetreq = new HTTP\HTTPRequest('https://docs.google.com/spreadsheets/d/' . $key . '/pub?single=true&gid=' . $sheetidx . '&output=csv');
     $gsheetreq->setFollowLocation(true);
     try {
         $gsheetresp = $gsheetreq->send();
         $csvdata = $gsheetresp->getBody();
     } catch (\Exception $e) {
         $csvdata = '';
     }
     $filename = tempnam('/tmp', 'edgecsv');
     file_put_contents($filename, $csvdata);
     parent::__construct($filename);
     $this->parse();
 }
Exemple #3
0
 private function determineEndPoints()
 {
     $request = new \HTTP\HTTPRequest(self::DISCOVERY_URL);
     $response = $request->send();
     $data = @json_decode($response->getBody(), true);
     if (empty($data['authorization_endpoint'])) {
         throw new \Exception('Failed to retrieve authentication endpoint from Google');
     } else {
         $this->endpoints = $data;
     }
 }
Exemple #4
0
 private function sendPublicMsg($channel, $msg)
 {
     $http = new \HTTP\HTTPRequest($this->app->config->slack->incoming_webhook);
     $http->setMethod('POST');
     $http->setRequestBody(json_encode(array('channel' => '#' . $channel, 'text' => $msg)));
     try {
         $http->send();
     } catch (Exception $e) {
     }
 }