/**
  * undocumented function
  *
  * @param unknown $user 
  * @param unknown $pass 
  * @return void
  * @access public
  */
 function login($user = null, $password = null)
 {
     if (empty($user)) {
         extract($this->config);
     }
     if (@empty($user) || @empty($password)) {
         return trigger_error('Please specify a user / password for using this service');
     }
     $post = array('continue' => 'http://www.google.com/analytics/home/?et=reset&hl=en-US', 'service' => 'analytics', 'nui' => 'hidden', 'hl' => 'en-US', 'GA3T' => 'ouVrvynQwUs', 'Email' => $user, 'PersistentCookie' => 'yes', 'Passwd' => $password);
     $response = $this->Http->post('https://www.google.com/accounts/ServiceLoginBoxAuth', $post);
     if (!strpos($response, 'TokenAuth?continue')) {
         return $this->connected = false;
     }
     $this->config['database'] = $user;
     return $this->connected = true;
 }
Esempio n. 2
0
 /**
  *
  * @return \Illuminate\Routing\Route
  */
 public function post()
 {
     // $response = $this->client->post($this->endpoint, $this->getRequestVars());
     // return new NvpResponse($result);
     try {
         // Grab the client's handler instance.
         $clientHandler = $this->client->getConfig('handler');
         // Create a middleware that echoes parts of the request.
         $tapMiddleware = Middleware::tap(function ($request) {
             print_r($request->getHeader('Content-Type'));
             // application/json
             echo $request->getBody() . "\n";
             echo $request->getUri() . "\n";
             // {"foo":"bar"}
         });
         $response = $this->client->post($this->endpoint, ['json' => $this->getRequestVars(), 'handler' => $tapMiddleware($clientHandler)]);
     } catch (GuzzleHttp\Exception\BadResponseException $e) {
         echo 'Uh oh! ' . $e->getMessage();
     }
     return $response;
 }
 /**
  * undocumented function
  *
  * @return void
  * @access public
  */
 function addProfile($profile)
 {
     if (!is_array($profile)) {
         $profile = array('url' => $profile);
     }
     $profile = am(array('domain' => null, 'name' => null, 'account' => null, 'countryCode' => null, 'timeZone' => null, 'post' => array()), $profile);
     $profile['account'] = $this->accountId($profile['account']);
     if ($profile['domain']) {
         $profile['domain'] = $this->profileId($profile['domain']);
     }
     if (is_string($profile['url'])) {
         preg_match('/(http|https)+:\\/\\/(.+)/', $profile['url'], $match);
         $profile['url'] = array('scheme' => $match[1], 'url' => $match[2]);
     }
     $post = am(array('aid' => 1101, 'vid' => 1151, 'rd' => 'vid=1100&scid=' . $profile['account'], 'usac_id' => null, 'ucpr_web_site_url' => null, 'uiti_id' => 293, 'uiti_id_orig' => 1, 'ubwe_new' => (int) (!$profile['domain']), 'ucpr_protocol' => $profile['url']['scheme'], 'ucpr_url' => $profile['url']['url'], 'uswe_id' => $profile['domain'], 'ucpr_name' => $profile['name'], 'ucpt_country_code' => $profile['countryCode'], 'tzCode' => $profile['timeZone']), $profile['post']);
     $response = $this->Http->post('https://www.google.com/analytics/home/admin?scid=' . $profile['account'], $post);
     if (!preg_match('/rid=([\\d]+)/', @$this->Http->response['header']['Location'], $match)) {
         return false;
     }
     $this->listSources(true);
     return (int) $match[1];
 }