\Gianism\ServiceMixi

mixi Controller

Summary

Methods
Properties
Constants
has_valid_refresh_token()
send_message()
is_connected()
disconnect()
refresh_button()
is_pseudo_mail()
mail_handler()
set_option()
parse_request()
handle_login()
profile_connect()
connection_message()
login_form()
filter_link()
button()
login_button()
connect_button()
disconnect_button()
user_can_register()
__get()
get_instance()
_()
e()
get()
post()
request()
nonce_action()
nonce_create()
nonce_field()
verify_nonce()
is_ssl_required()
is_enabled()
get_meta_owner()
get_service_instance()
$mixi_consumer_key
$mixi_consumer_secret
$mixi_access_token
$mixi_refresh_token
$umeta_id
$umeta_profile_url
$umeta_refresh_token
$url_prefix
$verbose_service_name
$message_key_name
$service_name
$enabled
$dir
$url
$all_services
$nonce_key_name
END_POINT
handle_refresh()
handle_default()
wp_mail()
get_api_url()
init_action()
__construct()
handle_connect()
handle_disconnect()
get_redirect_to()
get_action()
filter_redirect()
get_redirect_endpoint()
is_smartphone()
hook_connect()
hook_disconnect()
user_password_unknown()
valid_username_from_mail()
api_error_string()
duplicate_account_string()
welcome()
auth_fail()
mail_fail_string()
registration_error_string()
kill_wrong_access()
test_user_can_register()
get_response()
add_message()
wp_die()
session_write()
session_get()
session_delete()
$pseudo_domain
$option_keys
$name
$version
$domain
N/A
get_auth_endpoint()
get_access_token()
get_new_token()
get_profile()
get_endpoint()
$instances
$_all_services
N/A

Constants

END_POINT

END_POINT

Properties

$mixi_consumer_key

$mixi_consumer_key : string

Type

string

$mixi_consumer_secret

$mixi_consumer_secret : string

Type

string

$mixi_access_token

$mixi_access_token : string

Type

string

$mixi_refresh_token

$mixi_refresh_token : string

Type

string

$umeta_id

$umeta_id : string

User's mixi ID

Type

string

$umeta_profile_url

$umeta_profile_url : string

User's mixi profile page URL

Type

string

$umeta_refresh_token

$umeta_refresh_token : string

Refresh token

Type

string

$url_prefix

$url_prefix : string

URL prefix

If this property is empty, service name will be used. e.g. http://example.jp/facebook/

Type

string

$verbose_service_name

$verbose_service_name : string

Verbose service name

If not set, $this->service_name will be used;

Type

string

$message_key_name

$message_key_name : string

Message post type

Type

string

$service_name

$service_name : string

Type

string

$enabled

$enabled : bool

Type

bool

$dir

$dir : string

Type

string

$url

$url : string

Type

string

$all_services

$all_services : array

Type

array

$nonce_key_name

$nonce_key_name : string

Type

string

$pseudo_domain

$pseudo_domain : string

Pseudo domain

Type

string

$option_keys

$option_keys : array

Option key to retrieve

Type

array

$name

$name : string

Name

Used for option key, nonce, etc.

Type

string

$version

$version : string

Version number

Type

string

$domain

$domain : string

i18n Domain

Type

string

$instances

$instances : \Gianism\Singleton

Instance holder

Type

\Gianism\Singleton

$_all_services

$_all_services : array

All services

Type

array

Methods

has_valid_refresh_token()

has_valid_refresh_token() : boolean

Check if valid option is set.

Returns

boolean

send_message()

send_message(int $user_id, string $subject, string $body)

Send message via mixi

Parameters

int $user_id
string $subject
string $body

is_connected()

is_connected(int $user_id) : bool

Detect if user is connected to this service

Parameters

int $user_id

Returns

bool

disconnect()

disconnect(int $user_id) : mixed

Disconnect user from this service

Parameters

int $user_id

Returns

mixed

refresh_button()

refresh_button(string $redirect_to) : string

Get refresh token

Parameters

string $redirect_to

Returns

string

is_pseudo_mail()

is_pseudo_mail(string $mail) : bool

This controller reutrn always false

Parameters

string $mail

Returns

bool

mail_handler()

mail_handler(array $args) : array

Override default wp_mai

Parameters

array $args

Returns

array

set_option()

set_option() : void

Setup default option

parse_request()

parse_request(string $action, \WP_Query $wp_query) : void

Called on redirect endpoint

Parameters

string $action
\WP_Query $wp_query

handle_login()

handle_login(\WP_Query $wp_query)

Make user login

Parameters

\WP_Query $wp_query

profile_connect()

profile_connect(\WP_User $user) : void

Show connect button on profile page

Parameters

\WP_User $user

connection_message()

connection_message(string $context) : string

Connection message

Overriding this function, you can customize connection message

Parameters

string $context

Returns

string

login_form()

login_form(boolean $is_register) : void

Display login buttons

Parameters

boolean $is_register

filter_link()

filter_link(string $markup, string $href, string $text, bool $is_register) : string

Resturns link to filter

Parameters

string $markup
string $href
string $text
bool $is_register

Returns

string

button()

button(string $text, string $href, bool $icon_name, array $class_names, array $attributes) : string

Create common button

Parameters

string $text
string $href
bool $icon_name
array $class_names
array $attributes

Returns

string

login_button()

login_button(string $redirect, bool $register) : string

Show login button

Parameters

string $redirect
bool $register

Returns

string

connect_button()

connect_button(string $redirect_to) : string

Get connect button

Parameters

string $redirect_to

If not set, profile page's URL

Returns

string

disconnect_button()

disconnect_button(string $redirect_to) : string

Get disconnect button

Parameters

string $redirect_to

If not set, profile page's URL

Returns

string

user_can_register()

user_can_register() : bool

Detect if user can register

Returns

bool

__get()

__get(string $name) : mixed

Getter

Parameters

string $name

Returns

mixed

get_instance()

get_instance(array $argument) : self

Get instance

Parameters

array $argument

Returns

self

_()

_(string $string) : string

Alias of __

Parameters

string $string

Returns

string

e()

e(string $string)

Alias of _e

Parameters

string $string

get()

get(string $key) : mixed

Return $_GET

Parameters

string $key

Returns

mixed

post()

post(string $key) : mixed

Return $_POST

Parameters

string $key

Returns

mixed

request()

request(string $key) : mixed

return $_REQUEST

Parameters

string $key

Returns

mixed

nonce_action()

nonce_action(string $action) : string

Return nonce name with prefix

Parameters

string $action

Returns

string

nonce_create()

nonce_create(string $action) : string

Parameters

string $action

Returns

string

nonce_field()

nonce_field(string $action, bool $referrer)

Alias of wp_nonce_field

Parameters

string $action
bool $referrer

Default false.

verify_nonce()

verify_nonce(string $action, string $referrer) : boolean

Check nonce

Parameters

string $action
string $referrer

Returns

boolean

is_ssl_required()

is_ssl_required() : boolean

Returns if login is forced to use SSL.

To override it, use filter gianism_force_ssl_login

Returns

boolean

is_enabled()

is_enabled(string $service) : bool

Determine if service is enabled.

Parameters

string $service

If not specified, one of the services are enabled, return true.

Returns

bool

get_meta_owner()

get_meta_owner(string $key, string $value) : int

Retrieve user meta's owner ID

Parameters

string $key
string $value

Returns

int —

User ID. If not exists, return 0

get_service_instance()

get_service_instance(string $service) : null|\Gianism\Service\Common\Mail

Get service instance

Parameters

string $service

Returns

null|\Gianism\Service\Common\Mail

handle_refresh()

handle_refresh(\WP_Query $wp_query)

Handle auth action

Parameters

\WP_Query $wp_query

handle_default()

handle_default(string $action) : void

Handle callback request

This function must exit at last.

Parameters

string $action

wp_mail()

wp_mail(int $user_id, string $subject, string $message, array|string $headers, string $attachment) : void

Alternative wp_mail

Parameters

int $user_id
string $subject
string $message
array|string $headers
string $attachment

get_api_url()

get_api_url(string $action) : string|false

Return api URL to authenticate

If you need additional information (ex. token), use $this->session_write inside.

$this->session_write('token', $token); return $url;

Parameters

string $action

'connect', 'login'

Throws

\Exception

Returns

string|false —

URL to redirect

init_action()

init_action() : void

Initialize

If some stuff is required, override this.

__construct()

__construct(array $argument)

Constructor

Parameters

array $argument

handle_connect()

handle_connect(\WP_Query $wp_query)

Handle connect

Parameters

\WP_Query $wp_query

handle_disconnect()

handle_disconnect(\WP_Query $wp_query)

Handle disconnect

Parameters

\WP_Query $wp_query

get_redirect_to()

get_redirect_to(string $default, array $args) : string

Returns redirect to url if set.

Parameters

string $default
array $args

Returns

string

get_action()

get_action() : string

Returns current action name.

Returns

string

filter_redirect()

filter_redirect(string $url, string $context) : string

Filter redirect URL

Parameters

string $url
string $context

login, connect, disconnect

Returns

string

get_redirect_endpoint()

get_redirect_endpoint(string $action, string $nonce_key, array $args) : string

Get URL for immediate endpoint.

Parameters

string $action

'connect', 'disconnect', 'login' or else.

string $nonce_key

If empty, nonce won't be set.

array $args

Returns

string

is_smartphone()

is_smartphone() : boolean

Detect if current client is smartphone.

Returns

boolean

hook_connect()

hook_connect(int $user_id, mixed $data, bool $on_creation)

Fires connect hook

Parameters

int $user_id
mixed $data
bool $on_creation

hook_disconnect()

hook_disconnect(mixed $user_id)

Fires disconnect hook

Parameters

mixed $user_id

user_password_unknown()

user_password_unknown(int $user_id)

Use's password is automatically generated

Parameters

int $user_id

valid_username_from_mail()

valid_username_from_mail(string $email) : string

Create valid username from email address

Parameters

string $email

Throws

\Exception

Returns

string

api_error_string()

api_error_string() : string

Returns API error string

Returns

string

duplicate_account_string()

duplicate_account_string() : string

Message account duplication

Returns

string

welcome()

welcome(string $who)

Add welcome message

Parameters

string $who

auth_fail()

auth_fail(string $message)

Add error message

Parameters

string $message

mail_fail_string()

mail_fail_string() : string

Add error message

Returns

string

registration_error_string()

registration_error_string() : string

Registration error string

Returns

string

kill_wrong_access()

kill_wrong_access()

Kill wrong access

test_user_can_register()

test_user_can_register() : bool

Test if can register.

Throws

\Exception

Returns

bool

get_response()

get_response(string $endpoint, string|array $request, string $method, bool $json, array $additional_headers) : array|\stdClass|bool|null

Get Request

Parameters

string $endpoint
string|array $request
string $method

If x-www-form-urlencoded required, pass array or else, pass query string.

bool $json

if this request is JSON

array $additional_headers

Additional headers.

Returns

array|\stdClass|bool|null

add_message()

add_message(string $string, bool $error)

Add message to show

Parameters

string $string
bool $error

wp_die()

wp_die(string $message, int $status_code, bool $return)

Short hand for wp_die

Parameters

string $message
int $status_code
bool $return

session_write()

session_write(string $key, mixed $value)

Write session

Parameters

string $key
mixed $value

session_get()

session_get(string $key) : bool

Get session

After get, session key will be deleted.

Parameters

string $key

Returns

bool

session_delete()

session_delete(string $key)

Delete session

Parameters

string $key

get_auth_endpoint()

get_auth_endpoint(array $scope) : string

Returns auth endpoint

Parameters

array $scope

Returns

string

get_access_token()

get_access_token(string $code) : string

Get Access Token

Parameters

string $code

Returns

string

get_new_token()

get_new_token(string $refesh_token) : string

Refresh and get new access token.

Parameters

string $refesh_token

Returns

string

get_profile()

get_profile(string $token) : array

Get Use profile

Parameters

string $token

Returns

array

get_endpoint()

get_endpoint() : string

Get Endpoint URL

Returns

string