-
Notifications
You must be signed in to change notification settings - Fork 114
Design.Inviter
linzongshu edited this page May 28, 2014
·
15 revisions
- Page to display generated invitation link
- HTTP API:
- Get invitation link
- Get inviter info
- Allowed developer to customize link generator
-
user_inviter
Description Field Type Length Default value More Unique ID id unsigned int 10 NULL Unique, Not null, auto_increment User ID uid unsigned int 10 0 Not null Inviter ID inviter unsigned int 10 0 Not null Mode mode varchar 64 ' ' Not null, which mode do user get the registeration link, email ? direct link ... Active active tinyint 1 0 Not null Create time time_created unsigned int 10 0 Not null Site appkey appkey varchar 32 ' ' Not null, which site the user send the invitation -
Unique key
- uid
-
Key
- uid_appkey_active
- mode
-
Folder structure
- Namespace:
Module\User\Inviter
AbstractInviter
DirectLink
Email
- Namespace:
Custom\User\Inviter
(Considering latter)Msn
Message
Qq
Twitter
- ...
Class methods
-
generate()
- Generate invitation link, include the
ikey
params, required
- Generate invitation link, include the
-
resolve()
- Resolve params
ikey
from registeration link intouid
,appkey
andmode
, required
- Resolve params
-
render()
- Render HTML tags displayed in invitation page for user to copy its link, required
-
send()
- Send message to invitee if necessary, optional
- Front
- InviteController
- indexAction
- Description: show links or forms for inviting users
- Template: invite-index.phtml
- sendAction
- Description: process invitation sending
- indexAction
- InviteController
- enable_invite
- Whether to display the invitation page or provide invitation link
- invite_mode
- Invitation mode allowed
- invite_end_time
- When to end invitation activity, the inviter will still saved, but it will be disabled, therefore other site cannot fetch the inviter info
-
/api/user/invite/get-link
-
Desc: get invitation link
-
Params:
-
appkey
: appkey of site, required -
uid
: user id, required -
mode
: which mode link needed, optional, default value isdirect-link
, its value should be:- direct-link
-
-
HTTP authorization
- username
- password
-
Return
- JSON string
- status: request status
- data: link address string
- JSON string
-
Example:
function get($uri, $data, $options = array()) { if (isset($options['authorization'])) { $auth = $options['authorization']; }
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, $auth['username'] . ':' . $auth['password']); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $result = curl_exec($ch); return json_decode($result, true);
} $options = array( 'authorization' => array( 'httpauth' => 'basic', 'username' => 'zongshu', 'password' => 'zongshu', ), ); $data = array( 'uid' => 375, 'appkey' => 2, ); $uri = 'http://account.eefocus.com/api/user/invite/get-link'; $result = get($uri, $data, $options);
-
-
/api/user/invite/get
- Desc: get inviters info
- Params:
-
uid
: invitee user ID, optional -
appkey
: site appkey, optional -
inviter
: inviter user ID, optional -
mode
: invitation mode, optional -
active
: is active, optional
-
- HTTP authorization
- username
- password
- Return:
- JSON
- status: request status
- data:
- inviter: inviter user ID
- uid: invitee user ID
- mode: invitation mode
- appkey: site appkey
- time_created: registeration time of invitee
- active: is active
- JSON
- Example:
-
/api/user/invite/send
- Desc: send invitation message if needed
- Params:
-
mode
: which mode is used to send message (e.g. : email, message), required -
content
: message content, optional, template in user module will be used if it not be set
-
- Return
- JSON
- status: request status or message sending status
- JSON
- Example: