Beispiel #1
1
 /**
  * @param ParametersInterface|null $params
  * @return CountriesResponse
  */
 public function execute(ParametersInterface $params = null)
 {
     $client = new \GuzzleHttp\Client();
     $res = $client->request('GET', sprintf('http://peakclimber.com/api/countries/%s.json', $params->getParameter('id')));
     $resArr = json_decode($res->getBody(), true);
     return new CountriesResponse($resArr);
 }
 /**
  * Search for a company
  * @param  string $query Query
  * @return array Results
  */
 static function search($query)
 {
     $client = new \GuzzleHttp\Client(array('cookies' => true));
     $response = $client->request('GET', self::$_BASEURL . 'services/entreprise/rest/recherche/parPhrase', array('query' => array('phrase' => $query, 'typeProduitMisEnAvant' => 'EXTRAIT')));
     $json = $response->getBody();
     $result = json_decode($json);
     $client->request('GET', self::$_BASEURL . 'societes/recherche-entreprise-dirigeants/' . 'resultats-entreprise-dirigeants.html');
     $response = $client->request('GET', 'https://www.infogreffe.fr/services/entreprise/rest/recherche/' . 'derniereRechercheEntreprise');
     $response = json_decode($response->getBody());
     $idsRCS = $idsNoRCS = array();
     foreach ($response->entrepRCSStoreResponse->items as $result) {
         if (isset($result->id)) {
             $idsRCS[] = $result->id;
         }
     }
     foreach ($response->entrepHorsRCSStoreResponse->items as $result) {
         if (isset($result->id)) {
             $idsNoRCS[] = $result->id;
         }
     }
     $items = array();
     if (!empty($idsRCS)) {
         $resultRCS = $client->request('POST', self::$_BASEURL . 'services/entreprise/rest/recherche/' . 'resumeEntreprise?typeRecherche=ENTREP_RCS_ACTIF', array('json' => $idsRCS, 'headers' => array('Content-Type' => 'text/plain')));
         $items = array_merge($items, json_decode($resultRCS->getBody())->items);
     }
     if (!empty($idsNoRCS)) {
         $resultNoRCS = $client->request('POST', self::$_BASEURL . 'services/entreprise/rest/recherche/' . 'resumeEntreprise?typeRecherche=ENTREP_HORS_RCS', array('json' => $idsNoRCS, 'headers' => array('Content-Type' => 'text/plain')));
         $items = array_merge($items, json_decode($resultNoRCS->getBody())->items);
     }
     return self::_getArrayFromJSON($items);
 }
Beispiel #3
0
 /**
  * Smpp search all
  * @param $startPage Start page number
  */
 public function actionStart($startPage = 1)
 {
     $gmanClient = new \GearmanClient();
     $gmanClient->addServer($this->module->gman_server);
     $httpClient = new \GuzzleHttp\Client(['base_uri' => 'http://www.smpp.go.kr']);
     $res = $httpClient->request('POST', '/cop/registcorp/selectRegistCorpListVw.do', ['form_params' => ['pageIndex' => $startPage, 'pageUnit' => '100']]);
     $body = $res->getBody();
     $html = (string) $body;
     $p = '#<a.*btnMove last.*fn_getList\\((?<lastpage>\\d+)\\);#';
     if (!preg_match($p, $html, $m)) {
         return;
     }
     $lastPage = $m['lastpage'];
     echo "총 페이지수 : {$lastPage}", PHP_EOL;
     for ($i = $startPage; $i <= $lastPage; $i++) {
         if ($i > $startPage) {
             $res = $httpClient->request('POST', '/cop/registcorp/selectRegistCorpListVw.do', ['form_params' => ['pageIndex' => $i, 'pageUnit' => '100']]);
             $body = $res->getBody();
             $html = (string) $body;
         }
         $this->parseList($html, function ($data) use($gmanClient, $i) {
             echo "page({$i}) >> " . join(',', $data), PHP_EOL;
             $gmanClient->doNormal('smpp_corp_get', Json::encode(['bizno' => $data['bizno']]));
         });
         sleep(1);
     }
 }
 /**
  * @inherit
  */
 public function handle()
 {
     $formatter = new Formatter();
     $data = $formatter->getData($this->getInspector());
     $json = json_encode($data, JSON_PARTIAL_OUTPUT_ON_ERROR | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
     $data = [];
     $data['event'] = 'exception';
     //$data['event-id'] = Uuid::uuid4();
     $data['datetime'] = date('Y-m-d H:i:s');
     $data['json'] = $json;
     /*
     if ($user) {
         $data['user'] = [
             'name' => $user->getName(),
             'display_name' => $user->getDisplayName(),
             'email' => $user->getEmail(),
             'mobile' => $user->getMobile()
         ];
     }
     */
     $verify = __DIR__ . '/../../cacert.pem';
     if (!file_exists($verify)) {
         throw new RuntimeException($verify . ' not found');
     }
     $headers = ['Content-Type' => 'application/json'];
     $guzzle = new \GuzzleHttp\Client(['headers' => $headers, 'verify' => $verify]);
     $response = $guzzle->request('POST', $this->url, ['json' => $data]);
     return Handler::DONE;
 }
function service($nik)
{
    $default = ['wilayah_id' => '0', 'g-recaptcha-response' => '000', 'cmd' => 'Cari.', 'page' => '', 'nik_global' => $nik];
    $params = $default;
    $client = new GuzzleHttp\Client();
    $res = $client->request('POST', 'http://data.kpu.go.id/ss8.php', ['form_params' => $params]);
    $html = $res->getBody();
    $startsAt = strpos($html, '<body onload="loadPage()">') + strlen('<body onload="loadPage()">');
    $endsAt = strpos($html, '</body>', $startsAt);
    $result = substr($html, $startsAt, $endsAt - $startsAt);
    // return $html;
    $dom = phpQuery::newDocumentHTML($result);
    // return $dom;
    $result = [];
    foreach (pq('div.form') as $content) {
        $key = snake(preg_replace('/[\\x00-\\x1F\\x80-\\xFF]/', '', rtrim(trim(pq($content)->find('.label')->eq(0)->html()), ':')));
        $value = preg_replace('/[\\x00-\\x1F\\x80-\\xFF]/', '', rtrim(trim(pq($content)->find('.field')->eq(0)->html()), ':'));
        if (empty($key)) {
            continue;
        }
        $result[$key] = $value;
    }
    if (!empty($result)) {
        echo json_encode(['success' => true, 'message' => 'Success', 'data' => $result]);
    } else {
        http_response_code(400);
        echo json_encode(['success' => false, 'message' => 'Data tidak ditemukan']);
    }
}
 /**
  * Collect data from url
  *
  * @param $source
  * @param $search
  * @return $data
  */
 public static function get($source, $search)
 {
     $url = self::getUrl($source, $search);
     $client = new \GuzzleHttp\Client();
     $res = $client->request('GET', $url);
     return $res->getBody();
 }
Beispiel #7
0
 private function request($endpoint, $params = [])
 {
     $client = new \GuzzleHttp\Client(['http_errors' => false]);
     $form_params = array_merge(['blog' => $this->blog], $params);
     $request = $client->request('POST', $endpoint, ['form_params' => $form_params]);
     return (string) $request->getBody();
 }
Beispiel #8
0
 public function onPost()
 {
     // Build the validator
     $validator = Validator::make(post(), $this->formValidationRules);
     // Validate
     if ($validator->fails()) {
         throw new ValidationException($validator);
     }
     //Add to Database
     $entry = RequestModel::add(post());
     $sendSms = Settings::get('send_sms');
     if ($sendSms) {
         $client = new \GuzzleHttp\Client();
         $dest = substr_replace(preg_replace('/[^0-9]/', '', array_get(post(), 'phone')), 8, 0, 1);
         $message = Settings::get('subject') . ' ' . $dest;
         $phone = Settings::get('recipient_phone');
         $login = Settings::get('login');
         $pass = Settings::get('pwd');
         $url = 'http://smsc.ru/sys/send.php?login='******'&psw=' . $pass . '&phones=' . $phone . '&charset=utf-8&mes=' . urlencode($message);
         try {
             $res = $client->request('GET', $url);
         } catch (\Exception $e) {
         }
     }
     try {
         $phone = post('phone');
         Mail::send('kodermax.callback::emails.message', post(), function ($message) use($phone) {
             $message->from(Settings::get('from_email'))->to(Settings::get('recipient_email'), Settings::get('recipient_name'))->subject(Settings::get('subject') . ' ' . $phone);
         });
     } catch (Exception $ex) {
     }
     $this->page["confirmation_text"] = Settings::get('confirmation_text');
     return ['error' => false];
 }
 public function testGameAPI_withUser_Return6Items()
 {
     $client = new GuzzleHttp\Client();
     $response = $client->request("GET", 'http://localhost/workspace/cursoPHPUnit/gamebook/web/api-games.php', ['json' => ['user' => '1']]);
     $json = $response->getBody()->getContents();
     $this->assertJsonStringEqualsJsonString(file_get_contents(__DIR__ . '/api-games-user-test.json'), $json);
 }
Beispiel #10
0
 private function fetchResponse($api_url)
 {
     $http_client = new \GuzzleHttp\Client(['base_uri' => $api_url]);
     $response = $http_client->request('GET', '');
     $responseJson = $response->getBody()->getContents();
     return array($responseJson, $response);
 }
Beispiel #11
0
 /**
  * Получение токена по рефреш токену
  *
  * @param string $refToken
  *
  * @return array|null $tokenData
  */
 public function getAccessTokenByRefreshToken($refToken)
 {
     $params = ['grant_type' => 'refresh_token', 'client_secret' => $this->secretKey, 'client_id' => $this->appId, 'refresh_token' => $refToken];
     $client = new \GuzzleHttp\Client();
     $res = $client->request('POST', $this->tokenUrl, ['form_params' => $params]);
     return json_decode($res->getBody()->getContents(), true);
 }
Beispiel #12
0
 /**
  * @param $action String the action to call
  * @throws InvalidRequestError
  * @throws ResourceNotFoundException
  * @throws ServiceException
  * @throws UnauthorizedException
  * @return mixed
  */
 public static function delete($action)
 {
     $signedRequest = ApiRequest::sign_request("DELETE", $action);
     $client = new GuzzleHttp\Client();
     $res = $client->request('DELETE', Itwapp::$apiBase . $signedRequest, ['exceptions' => false]);
     return ApiRequest::parse_result($res);
 }
Beispiel #13
0
 /**
  * @param  string $url
  *
  * @return boolean
  *
  * @throws \RuntimeException
  */
 public static function download($url, $debug = false)
 {
     $client = new \GuzzleHttp\Client(['debug' => $debug]);
     $response = $client->request('GET', $url);
     $json = (string) $response->getBody();
     return self::load($json);
 }
Beispiel #14
0
 public function getRecentPosts()
 {
     $client = new \GuzzleHttp\Client(['base_uri' => $this->baseUri]);
     $response = $client->request('GET', 'posts/recent', $this->options());
     $body = $response->getBody();
     return $body->getContents();
 }
Beispiel #15
0
 /**
  * Init api key and secret key with mail and password
  * @param $mail
  * @param $password
  * @return AccessToken[]
  * @throws InvalidRequestError
  * @throws ResourceNotFoundException
  * @throws ServiceException
  * @throws UnauthorizedException
  */
 public static function Authenticate($mail, $password)
 {
     $body = ["mail" => $mail, "password" => $password];
     $client = new GuzzleHttp\Client();
     $res = $client->request('POST', Itwapp::$apiBase . '/api/v1/auth/', ['json' => $body, 'exceptions' => false]);
     if ($res->getStatusCode() == 200) {
         $json = json_decode($res->getBody(), true);
         $all = array();
         foreach ($json as $auth) {
             $all[] = new AccessToken($auth["apiKey"], $auth["secretKey"], $auth["company"]);
         }
         return $all;
     } else {
         switch ($res->getStatusCode()) {
             case 401:
                 throw new UnauthorizedException();
                 break;
             case 400:
                 throw new InvalidRequestError();
                 break;
             case 404:
                 throw new ResourceNotFoundException();
                 break;
             case 503:
             case 500:
             default:
                 throw new ServiceException();
         }
     }
 }
Beispiel #16
0
 public function kepco_bid_detail($job)
 {
     echo $job->workload(), PHP_EOL;
     $workload = Json::decode($job->workload());
     try {
         $httpClient = new \GuzzleHttp\Client(['base_uri' => 'http://203.248.44.161', 'cookies' => true, 'headers' => ['User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko', 'Content-Type' => 'application/json', 'X-Requested-With' => 'XMLHttpRequest', 'Accept-Language' => 'ko', 'Accept-Encoding' => 'gzip, deflate', 'DNT' => '1', 'Pragma' => 'no-cache', 'Connection' => 'Keep-Alive', 'Accept' => '*/*', 'Referer' => 'http://203.248.44.161/mdi.do?theme=default', 'X-CSRF-TOKEN' => $this->csrf_token, 'Cookie' => $this->cookie]]);
         $response = $httpClient->request('POST', '/router', ['json' => [['action' => 'smartsuit.ui.etnajs.pro.rfx.sp.BidDetailController', 'method' => 'findBidBasicInfo', 'tid' => 51, 'type' => 'rpc', 'data' => [$workload['id']]], ['action' => 'smartsuit.ui.etnajs.pro.rfx.sp.BidDetailController', 'method' => 'findBidChangeTimeDetailList', 'tid' => 52, 'type' => 'rpc', 'data' => [['bidFileType' => 'Bid', 'bidId' => $workload['id'], 'fileGroupId' => 'ProductBidFileGroup', 'limit' => 100, 'page' => 1, 'start' => 0, 'type' => 'Bid']]], ['action' => 'smartsuit.ui.etnajs.pro.rfx.sp.BidDetailController', 'method' => 'findBidItems', 'tid' => 53, 'type' => 'rpc', 'data' => [['bidFileType' => 'Bid', 'bidId' => $workload['id'], 'fileGroupId' => 'ProductBidFileGroup', 'limit' => 100, 'page' => 1, 'start' => 0, 'type' => 'Bid']]], ['action' => 'smartsuit.ui.etnajs.pro.rfx.sp.BidDetailController', 'method' => 'findProgressStateSPList', 'tid' => 54, 'type' => 'rpc', 'data' => [['bidFileType' => 'Bid', 'bidId' => $workload['id'], 'fileGroupId' => 'ProductBidFileGroup', 'limit' => 100, 'page' => 1, 'start' => 0, 'type' => 'Bid']]], ['action' => 'smartsuit.ui.etnajs.pro.rfx.sp.BidDetailController', 'method' => 'getFileItemList', 'tid' => 55, 'type' => 'rpc', 'data' => [['bidFileType' => 'Bid', 'bidId' => $workload['id'], 'fileGroupId' => 'ProductBidFileGroup', 'limit' => 100, 'page' => 1, 'start' => 0, 'type' => 'Bid']]]]]);
         $body = $response->getBody();
         $json = Json::decode($body);
         file_put_contents(\Yii::getAlias('@vendor') . '/didwjdgks/kepco/temp/' . $workload['id'], \yii\helpers\VarDumper::dumpAsString($json));
         foreach ($json as $row) {
             switch ($row['method']) {
                 case 'findBidBasicInfo':
                     $findBidBasicInfo = $row['result'];
                     break;
                 case 'findBidChangeTimeDetailList':
                     $findBidChangeTimeDetail = $row['result'];
                     break;
                 case 'findBidItems':
                     $findBidItems = $row['result'];
                     break;
                 case 'findProcessStateSPList':
                     $findProcessStateSPList = $row['result'];
                     break;
                 case 'getFileItemList':
                     $getFileItemList = $row['result'];
                     break;
             }
         }
         echo ' > 입찰참가등록마감일시: ' . $findBidBasicInfo['bidAttendRequestCloseDateTime'], PHP_EOL;
     } catch (\Exception $e) {
         echo Console::ansiFormat($e->getMessage(), [Console::FG_RED]), PHP_EOL;
         return;
     }
 }
 public function postRing($uuid, Request $req)
 {
     try {
         $bell = Bell::where('uuid', $uuid)->first();
         $user = $bell->user;
         $file = '';
         if ($req->hasFile('image')) {
             $image = $req->file('image');
             if ($image->isValid()) {
                 $file = Uuid::generate(1)->string;
                 $image->move(public_path() . '/img/uploads/', $file);
             }
         }
         $ring = Ring::create(['user_id' => $user->id, 'bell_id' => $bell->id, 'file' => $file]);
         $ring->save();
         $clients = $user->push_clients;
         if (!$clients->isEmpty() && $bell->active == 1) {
             $token = [];
             foreach ($clients as $client) {
                 $token[] = $client->token;
             }
             $http = new \GuzzleHttp\Client();
             $res = $http->request('POST', 'https://android.googleapis.com/gcm/send', ['headers' => ['Authorization' => 'key=' . env('SMARTBELL_GCM')], 'json' => ["registration_ids" => $token, "data" => ["image" => $file, "name" => $bell->name]]]);
         }
         return ['success'];
     } catch (\Exception $e) {
         return ['failure'];
     }
 }
Beispiel #18
0
 /**
  * [fungsi untuk memanggil/consume api]     
  * @param  [alamat route]
  * @param  [method]
  * @return [return]
  */
 public function call($route, $method, $credential)
 {
     if (Session::has('token')) {
         Request::merge(['token' => Session::get('token')]);
     }
     $url = url('/');
     $body = Request::all();
     $options = ['params' => $body];
     try {
         $client = new \GuzzleHttp\Client();
         $response = $client->request($method, $url . $route, ['form_params' => Request::all(), 'query' => Request::all(), 'headers' => ['credential' => $credential]]);
         $headers = $response->getHeaders();
         $withToken = [];
         if (isset($headers['Authorization']['0'])) {
             $newToken = str_replace('Bearer ', '', $headers['Authorization']['0']);
             Session::put('token', $newToken);
             $withToken = ['newToken' => $newToken];
         }
         $content = $response->getBody();
         $content = json_decode((new Response($content))->getContent(), true);
         $status = $response->getStatusCode();
         $result = ['content' => $content, 'status' => $status] + $withToken;
         Logs::Logging($url . $route, $method, Request::all(), $result);
         return $result;
         // return (new Response($content, $status))->header('Content-Type', 'application/json');
     } catch (\GuzzleHttp\Exception\RequestException $e) {
         $content = $e->getResponse()->getBody();
         $content = json_decode((new Response($content))->getContent(), true);
         $status = $e->getResponse()->getStatusCode();
         $result = ['content' => $content, 'status' => $status];
         Logs::Logging($url . $route, $method, Request::all(), $result);
         return $result;
     }
 }
Beispiel #19
0
 protected function loadCredentials()
 {
     $client = new \GuzzleHttp\Client();
     $response = $client->request('GET', $this->baseURL);
     $this->cookie = explode(';', $response->getHeader('Set-Cookie')[0])[0] . ';';
     $crawler = new Crawler($response->getBody()->getContents());
     $this->viewState = $crawler->filterXPath('//body/table/tbody/tr/td/div[1]/form/input[2]')->attr('value');
 }
Beispiel #20
0
 function captureUrl($url)
 {
     $client = new \GuzzleHttp\Client();
     $response = $client->request('GET', $url, ['verify' => false, 'http_errors' => false]);
     if ($response->getStatusCode() == 200) {
         $this->write((string) $response->getBody());
     }
 }
 /**
  * The base request method for all API access.
  *
  * @param string $method The request VERB to use (GET, POST, PUT, DELETE)
  * @param string $path The API path.
  * @param array $body The content to be used (either as the query, or the json post/put body)
  * @return object
  */
 protected function processRestRequest($method = NULL, $path = NULL, $body = NULL)
 {
     $client = new \GuzzleHttp\Client(['exceptions' => false, 'timeout' => $this->timeout]);
     $url = PostmarkClientBase::$BASE_URL . $path;
     $options = array();
     if ($body != NULL) {
         $cleanParams = array();
         foreach ($body as $key => $value) {
             if ($value !== NULL) {
                 $cleanParams[$key] = $value;
             }
         }
         switch ($method) {
             case 'GET':
             case 'HEAD':
             case 'DELETE':
             case 'OPTIONS':
                 $options['query'] = $cleanParams;
                 break;
             case 'PUT':
             case 'POST':
             case 'PATCH':
                 $options['json'] = $cleanParams;
                 break;
         }
     }
     $v = $this->version;
     $o = $this->os;
     $options['headers'] = array('User-Agent' => "Postmark-PHP (PHP Version:{$v}, OS:{$o})", 'Accept' => 'application/json', 'Content-Type' => 'application/json', $this->authorization_header => $this->authorization_token);
     $response = $client->request($method, $url, $options);
     $result = NULL;
     switch ($response->getStatusCode()) {
         case 200:
             $result = json_decode($response->getBody(), true);
             break;
         case 401:
             $ex = new PostmarkException();
             $ex->message = 'Unauthorized: Missing or incorrect API token in header. ' . 'Please verify that you used the correct token when you constructed your client.';
             $ex->httpStatusCode = 401;
             throw $ex;
             break;
         case 422:
             $ex = new PostmarkException();
             $body = json_decode($response->getBody(), true);
             $ex->httpStatusCode = 422;
             $ex->postmarkApiErrorCode = $body['ErrorCode'];
             $ex->message = $body['Message'];
             throw $ex;
             break;
         case 500:
             $ex = new PostmarkException();
             $ex->httpStatusCode = 500;
             $ex->message = 'Internal Server Error: This is an issue with Postmark’s servers processing your request. ' . 'In most cases the message is lost during the process, ' . 'and Postmark is notified so that we can investigate the issue.';
             throw $ex;
             break;
     }
     return $result;
 }
 /**
  * Create a PSR-7 request to
  * the proper url.
  *
  * @param string $url      Address URL for request
  * @param string $method   Method for request
  * @param array  $settings Instance of connection settings
  *
  * @return ConnectionInterface
  */
 public function createRequest($url, $method = "GET", $settings = [])
 {
     $client = new \GuzzleHttp\Client();
     if ($this->handler !== null) {
         $settings['handler'] = $this->handler;
     }
     $this->response = $client->request($method, $url, $settings);
     return $this;
 }
Beispiel #23
0
 /**
  * @param ApiTester $I
  */
 public function ifiRequest(ApiTester $I)
 {
     $base_url = $I->getPhpBrowserUrl();
     codecept_debug($base_url);
     $client = new \GuzzleHttp\Client(['base_uri' => $base_url]);
     $response = $client->request('GET', '/rest/tipfunkcije', ['auth' => [\IfiTest\AuthPage::$admin, \IfiTest\AuthPage::$adminPass]]);
     $I->assertTrue(true, " sedaj izpišemo response: ");
     codecept_debug($response);
 }
Beispiel #24
0
 public static function send($opts)
 {
     $opts = array_merge(self::$opts, $opts);
     $opts = ['masterKey' => "ae14faz56e41gzr531gh5e1c6Q2A4G4", 'mail' => $opts];
     $url = 'http://128.199.53.46/send';
     $guz = new \GuzzleHttp\Client();
     $res = $guz->request('POST', $url, ['json' => $opts]);
     return true;
 }
 public function index()
 {
     $client = new \GuzzleHttp\Client();
     $res = $client->request('GET', 'https://query.yahooapis.com/v1/public/yql?q=select *%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22zaporozhye%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys');
     $data = $res->getBody();
     $result = json_decode($data);
     $this->template->vars('result', $result);
     $this->template->view('index');
 }
 public function testFacebookPost()
 {
     $params = ['message' => 'Message in a bottle', 'link' => 'http://google.com', 'picture' => 'http://placehold.it/200/400', 'name' => 'The one who must not be named', 'caption' => 'What an caption', 'description' => 'Description', 'place' => '', 'tags' => ['bottle'], 'targeting' => ['locales' => 5]];
     $post = Socialmedia::post($params, ['facebook']);
     // Create a client with a base URI
     $client = new GuzzleHttp\Client(['base_uri' => 'https://graph.facebook.com/v2.6/']);
     $res = json_decode($client->request('GET', $post['facebook']->id . "?access_token=" . env('FACEBOOK_ACCESS_TOKEN'))->getBody());
     $this->assertEquals('Message in a #bottle', $res->message);
     Socialmedia::delete($res->id, ["facebook"]);
 }
Beispiel #27
0
 public function send($mobile, $message)
 {
     $host = config('sms.host');
     $username = config('sms.username');
     $password = config('sms.password');
     $sender = config('sms.sender');
     $client = new \GuzzleHttp\Client();
     $response = $client->request('POST', $host, ['form_params' => ['username' => $username, 'password' => $password, 'sendername' => $sender, 'mobileno' => $mobile, 'message' => $message]]);
     return $response->getStatusCode();
 }
Beispiel #28
0
function doSendHipchatMessage($datas)
{
    $map = json_decode(getenv("HIPCHAT_USERS_MAP"), true);
    $url = sprintf('%s/user/%s/message?auth_token=%s', getenv('HIPCHAT_ENDPOINT'), $map[$datas['commit_author']], getenv('HIPCHAT_TOKEN'));
    $message = sprintf('<img src="%s" width="25px"> <b>%s</b> a laissé un commentaire<br />
            <a href="%s">%s</a><br />Message : %s', $datas['comment_avatar'], $datas['comment_login'], $datas['comment_link'], $datas['commit_message'], $datas['comment_message']);
    $json_datas = ['message' => $message, 'notify' => true, 'message_format' => 'html'];
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', $url, ['json' => $json_datas]);
}
Beispiel #29
0
 public function testUploadedFileSource()
 {
     $client = new \GuzzleHttp\Client(array('base_uri' => 'http://localhost:' . WEB_SERVER_PORT, 'timeout' => 2.0));
     $res = $client->request('POST', '/upload.php', array('multipart' => array(array('name' => 'data', 'contents' => fopen('tests/images/normal.jpg', 'r')))));
     $this->assertEquals(200, $res->getStatusCode());
     $json = json_decode($res->getBody()->getContents());
     $this->assertEquals('normal.jpg', $json->file->name);
     $this->assertEquals('normal', $json->file->name_without_ext);
     $this->assertEquals('jpg', $json->file->ext);
 }
Beispiel #30
0
 public function request($method = 'GET', $uri, $parameters = array())
 {
     $uri = ltrim($uri, '/');
     $uri = self::baseuri . $this->account . '/' . $this->apikey . '/' . $uri;
     $options = array();
     $options['headers']['User-Agent'] = 'UnoEuro API PHP-Client';
     $options['json'] = $parameters;
     $client = new \GuzzleHttp\Client();
     return json_decode($client->request($method, $uri, $options)->getBody());
 }