完整版V1 加入爬虫功能
This commit is contained in:
@@ -11,9 +11,15 @@ class SplitFriendUrlBuilder
|
||||
{
|
||||
/**
|
||||
* 构建跳转 URL;无法构建时返回空字符串
|
||||
*
|
||||
* @param string $whatsAppReplyText 仅 WhatsApp 类型使用,预填消息文案(urlencode 在内部处理)
|
||||
*/
|
||||
public static function build(string $numberType, string $number, string $numberTypeCustom = ''): string
|
||||
{
|
||||
public static function build(
|
||||
string $numberType,
|
||||
string $number,
|
||||
string $numberTypeCustom = '',
|
||||
string $whatsAppReplyText = ''
|
||||
): string {
|
||||
$number = trim($number);
|
||||
if ($number === '') {
|
||||
return '';
|
||||
@@ -21,7 +27,7 @@ class SplitFriendUrlBuilder
|
||||
|
||||
switch ($numberType) {
|
||||
case 'whatsapp':
|
||||
return self::buildWhatsApp($number);
|
||||
return self::buildWhatsApp($number, $whatsAppReplyText);
|
||||
case 'telegram':
|
||||
return self::buildTelegram($number);
|
||||
case 'line':
|
||||
@@ -34,16 +40,22 @@ class SplitFriendUrlBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
* WhatsApp:https://api.whatsapp.com/send?phone= 仅数字
|
||||
* WhatsApp:https://api.whatsapp.com/send?phone= 仅数字,可选 &text= 预填消息
|
||||
*/
|
||||
private static function buildWhatsApp(string $number): string
|
||||
private static function buildWhatsApp(string $number, string $replyText = ''): string
|
||||
{
|
||||
$digits = preg_replace('/\D+/', '', $number) ?? '';
|
||||
if ($digits === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return 'https://api.whatsapp.com/send?phone=' . $digits;
|
||||
$url = 'https://api.whatsapp.com/send?phone=' . $digits;
|
||||
$replyText = trim($replyText);
|
||||
if ($replyText !== '') {
|
||||
$url .= '&text=' . rawurlencode($replyText);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user