/**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->bind('slackapi', function () {
         $client = new \GuzzleHttp\Client();
         $verify_path = config('services.slack.ssl_verify');
         if (!empty($verify_path) and file_exists($verify_path)) {
             $client->setDefaultOption('verify', $verify_path);
         }
         return new \Vluzrmos\SlackApi\SlackApi($client, config('services.slack.token'));
     });
 }
Пример #2
0
 private function uploadImg()
 {
     if (!file_exists($this->configs["filePath"])) {
         return "file not found";
     } else {
         $imageFile = file_get_contents($this->configs["filePath"]);
         if ($this->configs["service-name"] === "imgur") {
             $httpConfig = ['defaults' => ['headers' => ['Authorization' => 'Client-ID ' . $this->configs["clientID"]]]];
         }
         $httpClient = new \GuzzleHttp\Client($httpConfig);
         $httpClient->setDefaultOption('verify', false);
         $res = $httpClient->post('https://api.imgur.com/3/image.json', ['body' => ['image' => base64_encode($imageFile)]]);
         return $res->json();
     }
 }
Пример #3
0
 /**
  * Sends request to some API method.
  * @param string $method API method name.
  * @param array $params search and pagination/sort params.
  * @throws \Exception
  * @return mixed request json decoded response.
  */
 public function request($method, $params)
 {
     $client = new \GuzzleHttp\Client(['defaults' => ['exceptions' => false]]);
     $client->setDefaultOption('headers', ["Accept: application/json"]);
     $attributes = http_build_query(array_merge(['username' => $this->username, 'api_key' => $this->apiKey], $params));
     /**
      * @var \GuzzleHttp\Message\ResponseInterface $response
      */
     $response = $client->get($this->baseUrl . "/api/" . $method . "?" . $attributes);
     //echo $this->baseUrl . "/api/" . $method . "?" . $attributes;exit;
     $result = $response->json();
     if ($response->getStatusCode() != 200) {
         throw new \Exception($response->getStatusCode() . ": " . $result["message"]);
     }
     return $result;
 }
Пример #4
0
<?php

require_once 'app/init.php';
$googleClient = new Google_Client();
$guzzle = new GuzzleHttp\Client();
$guzzle->setDefaultOption('verify', 'C:/wamp/cacert.pem');
$auth = new GoogleAuth($googleClient);
if ($auth->checkRedirectCode()) {
    header('location:index.php');
}
?>

<!DOCTYPE html>
<html>
<head>
	<title>Google Sign in!</title>
</head>
<body>
	<?php 
if (!$auth->isLoggedIn()) {
    ?>
		
		<a href="<?php 
    echo $auth->getAuthUrl();
    ?>
">Sign in!</a>
	<?php 
} else {
    ?>
		<a href="logout.php">Logout!</a>
	<?php