private function registerMwClient()
 {
     $key = Config::get('app.key');
     $client = new \Guzzle\Service\Client('https://login.microweber.com/api/v1/client/');
     $domain = site_url();
     $domain = substr($domain, strpos($domain, '://') + 3);
     $domain = str_replace('/', '', $domain);
     $request = $client->createRequest('POST', "config/{$domain}");
     //dd($request, $request);
     $request->setPostField('token', $key);
     $response = $client->send($request);
     if (200 == $response->getStatusCode()) {
         $body = (string) $response->getBody();
         $body = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $body, MCRYPT_MODE_ECB);
         $body = trim($body);
         $body = (array) json_decode($body);
         Config::set('services.microweber', $body);
         Config::save();
         save_option(['option_value' => 'y', 'option_key' => 'enable_user_microweber_registration', 'option_group' => 'users']);
     } else {
         // $reason = $response->getReasonPhrase();
         // dd(__FILE__, $reason, $response->getStatusCode());
     }
 }
Exemple #2
0
<?php

include 'headers.php';
require_once 'guzzle.phar';
// http://server_ip:server_port/library/sections/sectionID/all - skip the sections and just get them all
$server_ip = $_GET['server_ip'];
$server_port = $_GET['server_port'];
$sectionID = $_GET['sectionID'];
$token = $_GET['token'];
$client = new Guzzle\Service\Client('http://' . $server_ip);
$commandURL = '/library/sections/' . $sectionID . '/all?' . TOKEN_PARAM . '=' . $token;
$request = $client->get($commandURL, array('Content-Length' => 0, HEADER_PLATFORM => VALUE_PLATFORM, HEADER_PLATFORM_VERSION => VALUE_PLATFORM_VERSION, HEADER_PROVIDES => VALUE_PROVIDES, HEADER_PRODUCT => VALUE_PRODUCT, HEADER_VERSION => VALUE_VERSION, HEADER_DEVICE => VALUE_DEVICE, HEADER_CLIENT => VALUE_CLIENT));
$request->setPort($server_port);
//$request->getCurlOptions()->set(CURLOPT_SSL_VERIFYHOST, false);
//$request->getCurlOptions()->set(CURLOPT_SSL_VERIFYPEER, false);
$response = $client->send($request);
echo $response->getBody();