本文整理汇总了PHP中Social类的典型用法代码示例。如果您正苦于以下问题:PHP Social类的具体用法?PHP Social怎么用?PHP Social使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Social类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mostrar_redes
public function mostrar_redes()
{
$social = new Social();
// id="social" al div principal
?>
<div>
<div class="social">
<?php
$social->button_gplus('standard');
?>
</div>
<div class="social">
<?php
$social->button_twitter_share('large');
?>
</div>
<div class="social">
<?php
$social->button_twitter_follow('codeando_org');
?>
</div>
<div class="social">
<?php
$social->button_fb_share();
?>
</div>
</div>
<?php
}
示例2: workOnUser
public function workOnUser($provider, $provideruser)
{
$userClass = Yii::app()->controller->module->userClass;
$social = Social::model()->find("provider='" . $provider . "' AND provideruser='" . $provideruser . "'");
if ($social) {
$user = $userClass::model()->find("id=" . $social->yiiuser);
return $user;
} else {
// no user is connected to that provideruser,
$social = new Social();
// a new relation will be needed
$social->provider = $provider;
// what provider
$social->provideruser = $provideruser;
// the unique user
// if a yii-user is already logged in add the provideruser to that account
if (!Yii::app()->user->isGuest) {
$social->yiiuser = Yii::app()->user->id;
$user = $userClass::model()->findByPk(Yii::app()->user->id);
} else {
// we want to create a new $userClass
$user = new $userClass();
$user->username = $provideruser;
if ($user->save()) {
//we get an user id
$social->yiiuser = $user->id;
}
}
if ($social->save()) {
return $user;
}
}
}
示例3: buildResponse
/**
* Converts the response in JSON format to the value object i.e Social
*
* @param json
* - response in JSON format
*
* @return Social object filled with json data
*
*/
public function buildResponse($json)
{
$slJSONObject = $this->getServiceJSONObject("social", $json);
$sl = new Social();
$sl->setStrResponse($json);
$sl->setResponseSuccess($this->isRespponseSuccess($json));
$this->buildObjectFromJSONTree($sl, $slJSONObject);
if ($slJSONObject->has("friends")) {
if ($slJSONObject->__get("friends") instanceof JSONObject) {
$friendJSONObj = $slJSONObject->__get("friends");
$friends = new Friends($sl);
$this->buildJsonFriends($friends, $friendJSONObj);
} else {
// There is an Array of attribute
$friendsJSONArray = $slJSONObject->getJSONArray("friends");
for ($i = 0; $i < count($friendsJSONArray); $i++) {
$friendJSONObj = $friendsJSONArray[$i];
$friends = new Friends($sl);
$this->buildJsonFriends($friends, $friendJSONObj);
}
}
}
if ($slJSONObject->has("profile")) {
if ($slJSONObject->__get("profile") instanceof JSONObject) {
$publicJSONObject = $slJSONObject->__get("profile");
$publicfriend = new PublicProfile($sl);
$this->buildJsonPublicProfile($publicfriend, $publicJSONObject);
} else {
// There is an Array of attribute
$profileJSONArray = $slJSONObject->getJSONArray("profile");
for ($i = 0; $i < count($profileJSONArray); $i++) {
$profileJSONObj = $profileJSONArray[$i];
$publicfriends = new PublicProfile($sl);
$this->buildJsonPublicProfile($publicfriends, $profileJSONObj);
}
}
}
if ($slJSONObject->has("me")) {
if ($slJSONObject->__get("me") instanceof JSONObject) {
$meJSONObj = $slJSONObject->__get("me");
$me = new SocialFacebookProfile($sl);
$this->buildJsonFacebookProfile($me, $meJSONObj);
}
}
if ($slJSONObject->has("facebookProfile")) {
if ($slJSONObject->__get("facebookProfile") instanceof JSONObject) {
$meJSONObj = $slJSONObject->__get("facebookProfile");
$me = new SocialFacebookProfile($sl);
$this->buildJsonFacebookProfileLink($me, $meJSONObj);
}
}
return $sl;
}
示例4: actionNewMessage
public function actionNewMessage() {
$time=time();
if (isset($_POST['message']) && $_POST['message'] != '') {
$user = Yii::app()->user->getName();
$chat = new Social;
$chat->data = $_POST['message'];
$chat->timestamp = $time;
$chat->user = $user;
$chat->type = 'chat';
if ($chat->save()) {
echo '1';
}
}
}
示例5: getObject
public static function getObject()
{
$class = get_called_class();
$class = substr($class, strrpos($class, '\\') + 1);
$object = Social::get($class, 'object_name');
return $object;
}
示例6: write
/**
* Add a message to the log.
*
* @static
* @param string $message message to add to the log
* @param array $args arguments to pass to the writer
* @param string $context context of the log message
* @param bool $backtrace show the backtrace
* @return void
*/
public function write($message, array $args = null, $context = null, $backtrace = false)
{
if (!Social::option('debug') and !in_array($context, apply_filters('social_log_contexts', array()))) {
return;
}
if ($args !== null) {
foreach ($args as $key => $value) {
$message = str_replace(':' . $key, $value, $message);
}
}
if ($context !== null) {
$context = '[' . strtoupper(str_replace('-', ' ', $context)) . '] ';
}
$error_str = $context . '[SOCIAL - ' . current_time('mysql', 1) . ' - ' . $_SERVER['REMOTE_ADDR'] . '] ' . $message;
if ($backtrace) {
ob_start();
debug_print_backtrace();
$trace = ob_get_contents();
ob_end_clean();
$error_str .= "\n\n" . $trace . "\n\n";
}
if (is_writable($this->_file)) {
error_log($error_str . "\n", 3, $this->_file);
} else {
error_log($error_str);
}
}
示例7: adminAuthenticate
public function adminAuthenticate()
{
$connections = array_filter(Social::getConnections(), function ($connection) {
return $connection['identifier'] and $connection['secret'];
});
return View::make('sentinel.admin-login.index', compact('connections'));
}
示例8: show
public function show()
{
// sitemap
$this->controller->setView('SitemapView');
$sitemap = $this->controller->display();
// legal notice
$left = array_key_exists('legal_notice', $this->config) ? $this->config['legal_notice'] : '';
$left = '<div class="col-md-6 col-md-offset-2"><p>' . $left . '</p></div>';
$right = '<div class="col-md-2"><p class="pull-right"><a href="#">Back to top</a></p></div>';
// social
$social = '';
$general = Config::getInstance()->getGeneralArray('general');
if (array_key_exists('social', $general) && $general['social']) {
$buttons = Social::getInstance()->socialButtons('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], Head::getInstance()->getTitle());
$span = floor(6 / count($buttons));
foreach ($buttons as $b) {
$social .= '<div class="col-xs-2 col-md-' . $span . ' text-center">' . $b . '</div>';
}
$x = floor((8 - count($buttons)) / 2);
$social = '<div class="row"><div class="col-md-offset-2 col-md-' . $x . '"></div>' . $social . '</div>';
}
// powered by
$poweredby = '';
if (isset($this->config['poweredby'])) {
$poweredby = '<p class="poweredby text-center">' . $this->config['poweredby'] . '</p>';
$poweredby = '<div class="row"><div class="col-md-8 col-md-offset-2">' . $poweredby . '</div></div>';
}
// put it together
return $sitemap . '<div class="footer-inner row">' . $left . $right . '</div>' . $social . $poweredby;
}
示例9: getCallback
/**
* Handles authentication
*
* @param string $slug
* @return mixed
*/
public function getCallback($slug)
{
try {
$user = Social::authenticate($slug, URL::current(), function ($link, $provider, $token, $slug) {
if ($slug == 'facebook') {
// Retrieve the user in question for modificiation
$user = $link->getUser();
// Get user details
$data = $provider->getUserDetails($token)->getArrayCopy();
// Update user details
$user->facebook_uid = $data['uid'];
$user->save();
} else {
if ($slug == 'twitter') {
// Retrieve the user in question for modificiation
$user = $link->getUser();
// Get user details
$data = $provider->getUserDetails($token);
// Update user details
$user->twitter_nickname = $data->nickname;
$user->twitter_image_url = $data->imageUrl;
$user->save();
}
}
});
return Redirect::to('oauth/authenticated');
} catch (Exception $e) {
return Redirect::to('oauth')->withErrors($e->getMessage());
}
}
示例10: getInstance
/**
* returns the instance created by its first invoke.
*
* @return Social
*/
public static function getInstance()
{
if (null === self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
示例11: actionEdit
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
*/
public function actionEdit()
{
$model = $this->loadUser();
$social = Social::model()->find("provider='facebook' AND yiiuser=" . Yii::app()->user->id);
$profile = $model->profile;
UWprofilepic::handleProfilePic($model, $profile);
// ajax validator
if (isset($_POST['ajax']) && $_POST['ajax'] === 'profile-form') {
echo UActiveForm::validate(array($model, $profile));
Yii::app()->end();
}
if (isset($_POST['Profile'])) {
$model->attributes = $_POST['User'];
$profile->attributes = $_POST['Profile'];
if ($model->validate() && $profile->validate()) {
$model->save();
$profile->save();
Yii::app()->user->setFlash('success', 'Your changes have been saved successfully.');
$this->redirect('/user/profile/edit/');
} else {
$profile->validate();
}
}
$this->render('edit', array('model' => $model, 'social' => $social, 'profile' => $profile));
}
示例12: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Social::create([]);
}
}
示例13: testAfterDelete
public function testAfterDelete()
{
$user = User::model()->findByPk('2');
if (X2_TEST_DEBUG_LEVEL > 1) {
/**/
print 'id of user to delete: ';
/**/
print $user->id;
}
// test calendar permissions deletion
$this->assertNotEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('user_id' => $user->id))));
$this->assertNotEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('other_user_id' => $user->id))));
// assert that group to user records exist for this user
$this->assertTrue(sizeof(GroupToUser::model()->findAllByAttributes(array('userId' => $user->id))) > 0);
$this->assertTrue($user->delete());
X2_TEST_DEBUG_LEVEL > 1 && (print 'looking for groupToUser records with userId = ' . $user->id);
GroupToUser::model()->refresh();
// assert that group to user records were deleted
$this->assertTrue(sizeof(GroupToUser::model()->findAllByAttributes(array('userId' => $user->id))) === 0);
// test profile deletion
$this->assertTrue(sizeof(Profile::model()->findAllByAttributes(array('username' => $user->username))) === 0);
// test social deletion
$this->assertTrue(sizeof(Social::model()->findAllByAttributes(array('user' => $user->username))) === 0);
$this->assertTrue(sizeof(Social::model()->findAllByAttributes(array('associationId' => $user->id))) === 0);
// test event deletion
$this->assertTrue(sizeof(Events::model()->findAll("user=:username OR (type='feed' AND associationId=" . $user->id . ")", array(':username' => $user->username))) === 0);
// test calendar permissions deletion
$this->assertEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('user_id' => $user->id))));
$this->assertEquals(0, sizeof(X2CalendarPermissions::model()->findAllByAttributes(array('other_user_id' => $user->id))));
}
示例14: action_login
public function action_login()
{
//if user loged in redirect home
if (Auth::instance()->logged_in()) {
Auth::instance()->login_redirect();
}
Social::include_vendor();
$user = FALSE;
$config = Social::get();
if ($this->request->query('hauth_start') or $this->request->query('hauth_done')) {
try {
Hybrid_Endpoint::process($this->request->query());
} catch (Exception $e) {
Alert::set(Alert::ERROR, $e->getMessage());
$this->redirect(Route::url('default'));
}
} else {
$provider_name = $this->request->param('id');
try {
// initialize Hybrid_Auth with a given file
$hybridauth = new Hybrid_Auth($config);
// try to authenticate with the selected provider
if ($provider_name == 'openid') {
$params = array('openid_identifier' => 'https://openid.stackexchange.com/');
} else {
$params = NULL;
}
$adapter = $hybridauth->authenticate($provider_name, $params);
if ($hybridauth->isConnectedWith($provider_name)) {
//var_dump($adapter->getUserProfile());
$user_profile = $adapter->getUserProfile();
}
} catch (Exception $e) {
Alert::set(Alert::ERROR, __('Error: please try again!') . " " . $e->getMessage());
$this->redirect(Route::url('default'));
}
//try to login the user with same provider and identifier
$user = Auth::instance()->social_login($provider_name, $user_profile->identifier);
//we couldnt login create account
if ($user == FALSE) {
$email = $user_profile->emailVerified != NULL ? $user_profile->emailVerified : $user_profile->email;
$name = $user_profile->firstName != NULL ? $user_profile->firstName . ' ' . $user_profile->lastName : $user_profile->displayName;
//if not email provided
if (!Valid::email($email, TRUE)) {
Alert::set(Alert::INFO, __('We need your email address to complete'));
//redirect him to select the email to register
$this->redirect(Route::url('default', array('controller' => 'social', 'action' => 'register', 'id' => $provider_name)) . '?uid=' . $user_profile->identifier . '&name=' . $name);
} else {
//register the user in DB
Model_User::create_social($email, $name, $provider_name, $user_profile->identifier);
//log him in
Auth::instance()->social_login($provider_name, $user_profile->identifier);
}
} else {
Alert::set(Alert::SUCCESS, __('Welcome!'));
}
$this->redirect(Session::instance()->get_once('auth_redirect', Route::url('default')));
}
}
示例15: verify_nonce
protected function verify_nonce()
{
$nonce = $this->request->query('_wpnonce');
if (!Social::wp39_verify_nonce($nonce, $this->request->action())) {
Social::log('NONCE Failure', array(), null, true);
wp_die('Oops, please try again.');
}
}