public directMessagesNew ( string[optional] $userId = null, string[optional] $screenName = null, string $text ) : array | ||
$userId | string[optional] | |
$screenName | string[optional] | |
$text | string | The text of your direct message. Be sure to URL encode as necessary, and keep the message under 140 characters. |
return | array |
public function directMessagesNew($userId = null, $screenName = null, $text)
{
// validate
if ($userId == null && $screenName == null) {
throw new Exception('One of user_id or screen_name are required.');
}
// build parameters
$parameters['text'] = (string) $text;
if ($userId != null) {
$parameters['user_id'] = (string) $userId;
}
if ($screenName != null) {
$parameters['screen_name'] = (string) $screenName;
}
// make the call
return $this->doCall('direct_messages/new.json', $parameters, true, 'POST');
}
/** * Tests Twitter->directMessagesNew */ public function testDirectMessagesNew() { $response = $this->twitter->directMessagesNew(null, 'tijs_dev', 'Running the tests.. 私のさえずりを設定する ' . time()); $this->isDirectMessage($response); $this->twitter->directMessagesDestroy($response['id']); }