$author = new SocialAuther\SocialAuther($vkAdapter); // аутентификация и вывод данных пользователя или вывод ссылки для аутентификации $_SESSION['code'] = $_GET['code']; if (!isset($_GET['code'])) { echo '<li><a style="font-size: 12pt" class="the-icons span-image" href="' . $author->getAuthUrl() . '"><span class="glyphicon glyphicon-user"></span></a></li>'; } else { if ($author->authenticate()) { echo <<<PPP <div class="navbar-header "> <a class="navbar-brand" href="#">You are logged</a> </div> PPP; if (!is_null($author->getSocialId())) { $_SESSION['socialId'] = $author->getSocialId(); } if (!is_null($author->getName())) { $_SESSION['name'] = $author->getName(); } if (!is_null($author->getEmail())) { $_SESSION['email'] = $author->getEmail(); } if (!is_null($author->getSocialPage())) { $_SESSION['socialPage'] = $author->getSocialPage(); } if (!is_null($author->getSex())) { $_SESSION['sex'] = $author->getSex(); } if (!is_null($author->getBirthday())) { $_SESSION['birthday'] = $author->getBirthday(); } // аватар пользователя
echo '<img src="' . $auther->getAvatar() . '" />'; } echo "<br />"; } } $facebookAdapterConfig = array('client_id' => '911528195635736', 'client_secret' => '2de1ab376d1c17cd47250920c05ab386', 'redirect_uri' => 'http://localhost/auth?provider=facebook'); $facebookAdapter = new SocialAuther\Adapter\Facebook($facebookAdapterConfig); $auther = new SocialAuther\SocialAuther($facebookAdapter); if (!isset($_GET['code'])) { echo '<p><a href="' . $auther->getAuthUrl() . '">Аутентификация через Facebook</a></p>'; } else { if ($auther->authenticate()) { if (!is_null($auther->getSocialId())) { echo "Социальный ID пользователя: " . $auther->getSocialId() . '<br />'; } if (!is_null($auther->getName())) { echo "Имя пользователя: " . $auther->getName() . '<br />'; } if (!is_null($auther->getEmail())) { echo "Email пользователя: " . $auther->getEmail() . '<br />'; } if (!is_null($auther->getSocialPage())) { echo "Ссылка на профиль пользователя: " . $auther->getSocialPage() . '<br />'; } if (!is_null($auther->getSex())) { echo "Пол пользователя: " . $auther->getSex() . '<br />'; } if (!is_null($auther->getBirthday())) { echo "День Рождения: " . $auther->getBirthday() . '<br />'; } // аватар пользователя
public function sauth() { if (!isset($this->request->get['provider'])) { $this->response->redirect(HTTP_CATALOG . '/social_error'); } $adapter = $this->request->get['provider']; $class = 'SocialAuther\\Adapter\\' . ucfirst($adapter); $adapter = new $class(SC::${$adapter}); $auther = new SocialAuther\SocialAuther($adapter); if ($auther->authenticate()) { $values = array('providerid' => $auther->getProvider(), 'socialid' => $auther->getSocialId(), 'name' => $auther->getName(), 'email' => $auther->getEmail(), 'page' => $auther->getSocialPage(), 'sex' => $auther->getSex(), 'birthday' => date('Y-m-d', strtotime($auther->getBirthday())), 'avatar' => $auther->getAvatar()); if (!$this->customer->loginsoc($values['providerid'], $values['socialid'])) { $this->load->model('account/customer'); $this->load->model('affiliate/affiliate'); $arr = array(); $arr['password'] = rand(0, 9999) . 'sasasasassfkskjsn'; $arr['providerid'] = $values['providerid']; $arr['socialid'] = $values['socialid']; $arr['firstname'] = $values['name']; $arr['email'] = $values['email']; $arr['lastname'] = ''; $arr['telephone'] = ''; $arr['fax'] = ''; $arr['company'] = ''; $arr['company_id'] = ''; $arr['tax_id'] = ''; $arr['address_1'] = ''; $arr['address_2'] = ''; $arr['city'] = ''; $arr['postcode'] = ''; $arr['country_id'] = '220'; $arr['zone_id'] = '3491'; $arr['agree'] = 'checked'; $arr['confirm'] = $arr['password']; $customer_id = $this->model_account_customer->addCustomer($arr); $afar = array('id' => $customer_id, 'firstname' => $arr['firstname'], 'lastname' => $arr['lastname'], 'email' => $arr['email'], 'telephone' => $arr['telephone'], 'fax' => $arr['fax'], 'password' => 'sadasfsfddsnjw', 'company' => $arr['company'], 'address_1' => $arr['address_1'], 'address_2' => $arr['address_2'], 'city' => $arr['city'], 'postcode' => $arr['postcode'], 'country_id' => $arr['country_id'], 'zone_id' => $arr['zone_id'], 'tax' => '', 'payment' => '', 'cheque' => '', 'paypal' => '', 'bank_name' => '', 'bank_branch_number' => '', 'bank_swift_code' => '', 'bank_account_name' => '', 'bank_account_number' => ''); $this->model_affiliate_affiliate->addAffiliate($afar); $this->customer->loginsoc($values['providerid'], $values['socialid']); $this->response->redirect($this->url->link('account/edit')); $this->customer->loginsoc($values['providerid'], $values['socialid']); } $this->response->redirect($this->url->link('account/profile')); $this->response->setOutput('providerid=' . $values['providerid'] . '<br>' . 'socialid=' . $values['socialid'] . '<br>' . 'name=' . $values['name'] . '<br>' . 'email=' . $values['email'] . '<br>'); } else { $this->response->redirect(HTTP_SERVER . 'social_error'); } }