Beispiel #1
0
 public static function feed_fb($token, $data)
 {
     $data = json_decode(base64_decode($data));
     if (!empty($data->id)) {
         if (!defined('_PATH_PRODUCT_')) {
             define('_PATH_PRODUCT_', Config::get('base_url') . Config::get('app.path.product'));
         }
         $product = \Model_Base_Product::get_one($data->id);
         $tmp = "\r\n\r\n--------------------------------------------------\r\n\r\n";
         $message = $product['product_name'] . $tmp . $product['product_description'] . $tmp . $product['product_info'];
         $groups = \Model_Base_GroupFb::get_all();
         foreach ($groups as $group) {
             try {
                 \OpauthStrategy::serverPost('https://graph.facebook.com/v2.5/' . $group['group_id'] . '/feed', array('access_token' => $token, 'message' => strip_tags(html_entity_decode($message, ENT_QUOTES)), 'link' => Uri::create('/product/' . $product['code']), 'caption' => 'WJ-SHOP', 'name' => html_entity_decode($product['product_name'], ENT_QUOTES), 'description' => html_entity_decode($product['product_description'], ENT_QUOTES), 'picture' => _PATH_PRODUCT_ . $product['product_photo']), null, $headers);
             } catch (\Exception $e) {
                 Log::error($e->getMessage());
             }
             sleep(5);
         }
     } elseif (!empty($data->message) && !empty($data->link)) {
         $groups = \Model_Base_GroupFb::get_all();
         foreach ($groups as $group) {
             try {
                 \OpauthStrategy::serverPost('https://graph.facebook.com/v2.5/' . $group['group_id'] . '/feed', array('access_token' => $token, 'message' => html_entity_decode($data->message, ENT_QUOTES), 'link' => $data->link), null, $headers);
             } catch (\Exception $e) {
                 Log::error($e->getMessage());
             }
             sleep(5);
         }
     }
 }
 public function __construct($strategy, $env)
 {
     parent::__construct($strategy, $env);
     $this->strategy['consumer_key'] = $this->strategy['consumer_key'];
     $this->strategy['consumer_secret'] = $this->strategy['consumer_secret'];
     require dirname(__FILE__) . '/../../Vendor/tmhOAuth/tmhOAuth.php';
     $this->tmhOAuth = new tmhOAuth($this->strategy);
 }
 public function __construct($strategy, $env)
 {
     parent::__construct($strategy, $env);
     $parsed = parse_url($this->env['host']);
     $this->openid = new LightOpenID($parsed['host']);
     $this->openid->required = $this->strategy['required'];
     $this->openid->optional = $this->strategy['optional'];
 }
Beispiel #4
0
 /**
  * Request
  */
 public function __construct($strategy, $env)
 {
     parent::__construct($strategy, $env);
     if (!session_id()) {
         session_start();
     }
     require dirname(__FILE__) . '/Vendor/YahooOAuthApplication.class.php';
     $this->yauth = new YahooOAuthApplication($this->strategy['key'], $this->strategy['secret'], $this->strategy['appid']);
 }
 public function __construct($strategy, $env)
 {
     parent::__construct($strategy, $env);
     $parsed = parse_url($this->env['host']);
     require dirname(__FILE__) . '/Vendor/lightopenid/openid.php';
     $this->openid = new LightOpenID($parsed['host']);
     $this->openid->required = $this->strategy['required'];
     $this->openid->optional = $this->strategy['optional'];
 }
 /**
  * Constructor, change defaults array for get online url
  * 
  * @param array $strategy Strategy-specific configuration
  * @param array $env Safe env values from Opauth, with critical parameters stripped out
  */
 public function __construct($strategy, $env)
 {
     parent::__construct($strategy, $env);
     $this->strategy['redirect_uri'] = get_site_url() . $this->strategy['redirect_uri'];
     // Login Cidadao validate url, so no child blog url here
     /*$redirect_uri = network_site_url();
     		$redirect_uri = rtrim($redirect_uri,"/");
     		$this->strategy['redirect_uri'] = $redirect_uri.$this->strategy['redirect_uri'];*/
 }
 public function __construct($strategy, $env)
 {
     parent::__construct($strategy, $env);
     $this->strategy['consumer_key'] = $this->strategy['key'];
     $this->strategy['consumer_secret'] = $this->strategy['secret'];
     $this->strategy['request_token_url'] = $this->strategy['base_url'] . $this->strategy['request_token_path'];
     $this->strategy['authorize_url'] = $this->strategy['base_url'] . $this->strategy['authorize_path'];
     $this->strategy['access_token_url'] = $this->strategy['base_url'] . $this->strategy['access_token_path'];
     require dirname(__FILE__) . '/Vendor/OAuthSimple.php';
     $this->oauth = new OAuthSimple($this->strategy['consumer_key'], $this->strategy['consumer_secret']);
 }
Beispiel #8
0
 /**
  * @runInSeparateProcess
  */
 public function testClientGet()
 {
     $url = 'http://example.test.org';
     $data = array('abc' => 'def', 'hello' => array('world', 'mars' => 'attack'), 'more""funny ' => 'element$"');
     $fullUrl = $url . '?' . http_build_query($data, '', '&');
     $headers_list = xdebug_get_headers();
     $this->assertNotContains("Location: {$url}", $headers_list);
     $this->assertNotContains("Location: {$fullUrl}", $headers_list);
     OpauthStrategy::clientGet($url, $data, false);
     $headers_list = xdebug_get_headers();
     $this->assertNotContains("Location: {$url}", $headers_list);
     $this->assertContains("Location: {$fullUrl}", $headers_list);
 }
Beispiel #9
0
 /**
  * Validate $auth response
  * Accepts either function call or HTTP-based call
  * 
  * @param string $input = sha1(print_r($auth, true))
  * @param string $timestamp = $_REQUEST['timestamp'])
  * @param string $signature = $_REQUEST['signature']
  * @param string $reason Sets reason for failure if validation fails
  * @return boolean true: valid; false: not valid.
  */
 public function validate($input = null, $timestamp = null, $signature = null, &$reason = null)
 {
     $functionCall = true;
     if (!empty($_REQUEST['input']) && !empty($_REQUEST['timestamp']) && !empty($_REQUEST['signature'])) {
         $functionCall = false;
         $provider = $_REQUEST['input'];
         $timestamp = $_REQUEST['timestamp'];
         $signature = $_REQUEST['signature'];
     }
     $timestamp_int = strtotime($timestamp);
     if ($timestamp_int < strtotime('-' . $this->env['security_timeout']) || $timestamp_int > time()) {
         $reason = "Auth response expired";
         return false;
     }
     $hash = OpauthStrategy::hash($input, $timestamp, $this->env['security_iteration'], $this->env['security_salt']);
     if (strcasecmp($hash, $signature) !== 0) {
         $reason = "Signature does not validate";
         return false;
     }
     return true;
 }
Beispiel #10
0
 public function __construct($strategy, $env)
 {
     parent::__construct($strategy, $env);
     $this->strategy['strategy_callback_url'] = $this->strategy['callback_url'];
     $this->openid = new LightOpenID($this->strategy['domain']);
 }
Beispiel #11
0
 /**
  * @depends testValidate
  */
 public function testValidateTimeout(array $response)
 {
     $config = array('security_salt' => 'k9QVRc7R3woOOVyJgOFBv2Rp9bxQsGtRbaOraP7ePXuyzh0GkrNckKjI4MV1KOy', 'security_iteration' => 919, 'security_timeout' => '1 minute');
     $response['timestamp'] = date('c', time() - 90);
     $response['signature'] = OpauthStrategy::hash(sha1(print_r($response['auth'], true)), $response['timestamp'], $config['security_iteration'], $config['security_salt']);
     $Opauth = self::instantiateOpauthForTesting($config);
     $this->assertFalse($Opauth->validate(sha1(print_r($response['auth'], true)), $response['timestamp'], $response['signature'], $reason));
     $this->assertEquals($reason, 'Auth response expired');
 }
 /**
  * Setup strategy
  *
  * @since 1.0
  * @param array $strategy Strategy-specific configuration
  * @param array $env Safe env values from Opauth, with critical parameters stripped out
  */
 public function __construct($strategy, $env)
 {
     parent::__construct($strategy, $env);
     $this->api_endpoint = 'live' == $this->strategy['environment'] ? self::LIVE_API_ENDPOINT : self::SANDBOX_API_ENDPOINT;
     $this->auth_endpoint = 'live' == $this->strategy['environment'] ? self::LIVE_AUTH_ENDPOINT : self::SANDBOX_AUTH_ENDPOINT;
 }
Beispiel #13
0
 private function fb_get_me($access_token = null)
 {
     if (!empty($access_token)) {
         try {
             $me = OpauthStrategy::serverGet('https://graph.facebook.com/me', array('access_token' => $access_token, 'locale' => 'ja_JP'), null, $headers);
             if (!empty($me)) {
                 $me_info = json_decode($me);
                 if (!empty($me_info->last_name)) {
                     Session::set('auth-strategy.user.last_name', $me_info->last_name);
                 }
                 if (!empty($me_info->first_name)) {
                     Session::set('auth-strategy.user.first_name', $me_info->first_name);
                 }
             }
         } catch (Exception $e) {
             //
         }
     } else {
         Response::redirect('/user/facebook');
     }
 }
Beispiel #14
0
 public function __construct($strategy, $env)
 {
     $this->defaults = (require dirname(__FILE__) . '/defaults.config.php');
     parent::__construct($strategy, $env);
 }
Beispiel #15
0
 public function testArrayReplaceRecursive()
 {
     $array = array('http' => array('method' => 'POST', 'content' => 'lorem ipsum'));
     $replacement = array('http' => array('content' => 'New content', 'new_key' => 'some value'), 'another_key' => 919);
     $replaced = OpauthStrategy::arrayReplaceRecursive($array, $replacement);
     $this->assertEquals($replaced, array('http' => array('method' => 'POST', 'content' => 'New content', 'new_key' => 'some value'), 'another_key' => 919));
 }