Methods summary
public
|
#
__construct( array $options = array() )
Constructor
Parameters
Throws
InvalidArgumentException When option "wei" is not an instance of "Wei\Wei"
Overrides
|
public
|
#
__invoke( )
Start up WeChat application and output the matched rule message
Start up WeChat application and output the matched rule message
Returns
$this
|
public
string|false
|
#
run( )
Execute the matched rule and returns the rule result
Execute the matched rule and returns the rule result
Returns false when the token is invalid or no rules matched
Returns
string|false
|
public
boolean
|
#
isVerifyToken( )
Check if the request is verify the token string
Check if the request is verify the token string
Returns
boolean
|
public
|
#
subscribe( Closure $fn )
Attach a callback which triggered when user subscribed you
Attach a callback which triggered when user subscribed you
Parameters
Returns
$this
|
public
|
#
unsubscribe( Closure $fn )
Attach a callback which triggered when user unsubscribed you
Attach a callback which triggered when user unsubscribed you
Parameters
Returns
$this
|
public
|
#
click( string $key, Closure $fn )
Attach a callback which triggered when user click the custom menu
Attach a callback which triggered when user click the custom menu
Parameters
- $key
- The key of event
- $fn
Returns
$this
|
public
|
#
scan( Closure $fn )
Attach a callback which triggered when user scan the QR Code
Attach a callback which triggered when user scan the QR Code
Parameters
Returns
$this
|
public
|
#
is( string $keyword, Closure $fn )
Attach a callback which triggered when user input equals to the keyword
Attach a callback which triggered when user input equals to the keyword
Parameters
- $keyword
- The keyword to compare with user input
- $fn
Returns
$this
|
public
|
#
has( string $keyword, Closure $fn )
Attach a callback with a keyword, which triggered when user input contains the keyword
Attach a callback with a keyword, which triggered when user input contains the keyword
Parameters
- $keyword
- The keyword to search in user input
- $fn
Returns
$this
|
public
|
#
startsWith( string $keyword, Closure $fn )
Attach a callback with a keyword, which triggered when user input starts with the keyword (case insensitive)
Attach a callback with a keyword, which triggered when user input starts with the keyword (case insensitive)
Parameters
- $keyword
- The keyword to search in user input
- $fn
Returns
$this
|
public
|
#
match( string $pattern, Closure $fn )
Attach a callback with a regex pattern which triggered when user input match the pattern
Attach a callback with a regex pattern which triggered when user input match the pattern
Parameters
- $pattern
- The pattern to match
- $fn
Returns
$this
|
public
|
#
receiveImage( Closure $fn )
Attach a callback to handle image message
Attach a callback to handle image message
Parameters
Returns
$this
|
public
|
#
receiveLocation( Closure $fn )
Attach a callback to handle location message
Attach a callback to handle location message
Parameters
Returns
$this
|
public
|
#
receiveVoice( Closure $fn )
Attach a callback to handle voice message
Attach a callback to handle voice message
Parameters
Returns
$this
|
public
|
#
receiveVideo( Closure $fn )
Attach a callback to handle video message
Attach a callback to handle video message
Parameters
Returns
$this
|
public
|
#
receiveLink( Closure $fn )
Attach a callback to handle link message
Attach a callback to handle link message
Parameters
Returns
$this
|
public
boolean
|
#
defaults( Closure $fn )
Attach a handler which executes when none of the rule handled the input
Attach a handler which executes when none of the rule handled the input
Parameters
Returns
boolean
|
public
array
|
#
sendText( string $content )
Generate text message for output
Generate text message for output
Parameters
Returns
array
|
public
array
|
#
sendMusic( string $title, string $description, string $url, string $hqUrl = null )
Generate music message for output
Generate music message for output
Parameters
- $title
- The title of music
- $description
- The description display blow the title
- $url
- The music URL for player
- $hqUrl
- The HQ music URL for player when user in WIFI
Returns
array
|
public
array
|
#
sendArticle( array $articles )
Generate article message for output
Generate article message for output
// Sends one article
$app->sendArticle(array( 'title' => 'The title of article', 'description' => 'The description of article', 'picUrl' => 'The picture URL of article', 'url' => 'The URL link to of article'
));
// Sends two or more articles
$app->sendArticle(array( array( 'title' => 'The title of article', 'description' => 'The description of article', 'picUrl' => 'The picture URL of article', 'url' => 'The URL link to of article' ), array( 'title' => 'The title of article', 'description' => 'The description of article', 'picUrl' => 'Te picture URL of article', 'url' => 'The URL link to of article' ), // more... ));
Parameters
- $articles
- The article array
Returns
array
|
public
boolean
|
#
isValid( )
Returns if the token is valid
Returns if the token is valid
Returns
boolean
|
public
mixed
|
#
getAttr( string $name )
Returns the XML element value
Returns the XML element value
Parameters
Returns
mixed
|
public
array
|
#
getAttrs( )
Returns all of XML element values
Returns all of XML element values
Returns
array
|
public
string
|
#
getPostData( )
Returns the HTTP raw post data
Returns the HTTP raw post data
Returns
string
|
public
string
|
|
public
string
|
#
getFromUserName( )
Returns the user openID who sent message to you
Returns the user openID who sent message to you
Returns
string
|
public
string
|
#
getCreateTime( )
Returns the timestamp when message created
Returns the timestamp when message created
Returns
string
|
public
string
|
#
getContent( )
Returns the user input string, available when the message type is text
Returns the user input string, available when the message type is text
Returns
string
|
public
string
|
#
getMsgId( )
Returns the message id
Returns
string
|
public
string
|
#
getMsgType( )
Returns the message type
Currently could be text, image, location, link, event, voice, video
Returns
string
|
public
string
|
#
getPicUrl( )
Returns the picture URL, available when the message type is image
Returns the picture URL, available when the message type is image
Returns
string
|
public
string
|
#
getLocationX( )
Returns the latitude of location, available when the message type is location
Returns the latitude of location, available when the message type is location
Returns
string
|
public
string
|
#
getLocationY( )
Returns the longitude of location, available when the message type is location
Returns the longitude of location, available when the message type is location
Returns
string
|
public
string
|
#
getLabel( )
Returns the detail address of location, available when the message type is location
Returns the detail address of location, available when the message type is location
Returns
string
|
public
string
|
#
getScale( )
Returns the scale of map, available when the message type is location
Returns the scale of map, available when the message type is location
Returns
string
|
public
string
|
#
getMediaId( )
Returns the media id, available when the message type is voice or video
Returns the media id, available when the message type is voice or video
Returns
string
|
public
string
|
#
getFormat( )
Returns the media format, available when the message type is voice
Returns the media format, available when the message type is voice
Returns
string
|
public
string
|
#
getEvent( )
Returns the type of event, could be subscribe, unsubscribe or CLICK, available when the message type is event
Returns the type of event, could be subscribe, unsubscribe or CLICK, available when the message type is event
Returns
string
|
public
string
|
#
getEventKey( )
Returns the key value of custom menu, available when the message type is event
Returns the key value of custom menu, available when the message type is event
Returns
string
|
public
string
|
#
getScanSceneId( )
Returns the scene id from the scan result, available when the message event is subscribe or scan
Returns the scene id from the scan result, available when the message event is subscribe or scan
Returns
string
|
public
string
|
#
getThumbMediaId( )
Returns the thumbnail id of video, available when the message type is video
Returns the thumbnail id of video, available when the message type is video
Returns
string
|
public
string
|
#
getTitle( )
Returns the title of URL, available when the message type is link
Returns the title of URL, available when the message type is link
Returns
string
|
public
string
|
#
getDescription( )
Returns the description of URL, available when the message type is link
Returns the description of URL, available when the message type is link
Returns
string
|
public
string
|
#
getUrl( )
Returns the URL link, available when the message type is link
Returns the URL link, available when the message type is link
Returns
string
|
public
string
|
#
getTicket( )
Returns the ticket string, available when user scan from the QR Code
Returns the ticket string, available when user scan from the QR Code
Returns
string
|
public
boolean|string
|
#
getKeyword( )
Returns the user inputted content or clicked button value
Returns the user inputted content or clicked button value
Returns
boolean|string
|
protected
array
|
#
send( string $type, array $response )
Generate message for output
Generate message for output
Parameters
- $type
- The type of message
- $response
- The response content
Returns
array
|
protected
|
#
addTextRule( string $type, string $keyword, Closure $fn )
Adds a rule to handle user text input
Adds a rule to handle user text input
Parameters
Returns
$this
|
protected
|
#
addEventRule( string $name, string $key, Closure $fn )
Adds a rule to handle user event, such as click, subscribe
Adds a rule to handle user event, such as click, subscribe
Parameters
Returns
$this
|
protected
|
#
parsePostData( )
Parse post data to receive user OpenID and input content and message attr
Parse post data to receive user OpenID and input content and message attr
|
protected
string|false
|
|
protected
|
|
protected
string
|
#
handle( Closure $fn )
Executes callback handler
Executes callback handler
Parameters
Returns
string
|
protected
SimpleXMLElement
|
#
arrayToXml( array $array, SimpleXMLElement $xml = null )
Convert to XML element
Parameters
Returns
SimpleXMLElement
|