neutrinoapi/neutrinoapi_php_sdk

此包已被弃用且不再维护。作者建议使用 neutrino_api/neutrino_api_client 包。

通用API

3.4.5 2019-11-13 22:17 UTC

This package is not auto-updated.

Last update: 2024-01-29 23:55:55 UTC


README

通用API

初始化

认证

为了设置API客户端的认证和初始化,您需要以下信息。

参数 描述
userId 您的用户ID
apiKey 您的API密钥

API客户端可以按以下方式初始化。

$userId = 'userId'; // Your user ID
$apiKey = 'apiKey'; // Your API key

$client = new NeutrinoAPILib\NeutrinoAPIClient($userId, $apiKey);

类参考

控制器列表

Class: 图像处理

获取单例实例

可以从API客户端访问Imaging类的单例实例。

$imaging = $client->getImaging();

Method: imageResize

调整图像大小并输出为JPEG或PNG。请参阅:https://www.neutrinoapi.com/api/image-resize/

function imageResize(
        $imageUrl,
        $width,
        $height,
        $format = 'png')

参数

参数 标签 描述
imageUrl 必需 源图像的URL
width 必需 调整到的宽度(以px为单位),同时保持纵横比
height 必需 调整到的高度(以px为单位),同时保持纵横比
format 可选 默认值 输出图像格式,可以是png或jpg

示例用法

$imageUrl = 'image-url';
$width = 19;
$height = 19;
$format = 'png';

$result = $imaging->imageResize($imageUrl, $width, $height, $format);

Method: qRCode

生成一个PNG格式的二维码。查看:https://www.neutrinoapi.com/api/qr-code/

function qRCode(
        $content,
        $width = 256,
        $height = 256,
        $fgColor = '#000000',
        $bgColor = '#ffffff')

参数

参数 标签 描述
content 必需 要编码到二维码中的内容(例如URL或电话号码)
width 可选 默认值 二维码的宽度(以像素为单位)
height 可选 默认值 二维码的高度(以像素为单位)
fgColor 可选 默认值 二维码前景颜色
bgColor 可选 默认值 二维码背景颜色

示例用法

$content = 'content';
$width = 256;
$height = 256;
$fgColor = '#000000';
$bgColor = '#ffffff';

$result = $imaging->qRCode($content, $width, $height, $fgColor, $bgColor);

方法: imageWatermark

使用另一张图片为图片添加水印。查看:https://www.neutrinoapi.com/api/image-watermark/

function imageWatermark(
        $imageUrl,
        $watermarkUrl,
        $opacity = 50,
        $format = 'png',
        $position = 'center',
        $width = null,
        $height = null)

参数

参数 标签 描述
imageUrl 必需 源图像的URL
watermarkUrl 必需 水印图片的URL
opacity 可选 默认值 水印的不透明度(0到100)
format 可选 默认值 输出图像格式,可以是png或jpg
position 可选 默认值 水印图片的位置,可能的值有:center, top-left, top-center, top-right, bottom-left, bottom-center, bottom-right
width 可选 如果设置,则按比例调整生成的图像宽度(以像素为单位)
height 可选 如果设置,则按比例调整生成的图像高度(以像素为单位)

示例用法

$imageUrl = 'image-url';
$watermarkUrl = 'watermark-url';
$opacity = 50;
$format = 'png';
$position = 'center';
$width = 19;
$height = 19;

$result = $imaging->imageWatermark($imageUrl, $watermarkUrl, $opacity, $format, $position, $width, $height);

方法: hTML5Render

将HTML内容渲染为PDF、JPG或PNG。查看:https://www.neutrinoapi.com/api/html5-render/

function hTML5Render(
        $content,
        $format = 'PDF',
        $pageSize = 'A4',
        $title = null,
        $margin = 0,
        $marginLeft = 0,
        $marginRight = 0,
        $marginTop = 0,
        $marginBottom = 0,
        $landscape = false,
        $zoom = 1,
        $grayscale = false,
        $mediaPrint = false,
        $mediaQueries = false,
        $forms = false,
        $css = null,
        $imageWidth = 1024,
        $imageHeight = null,
        $renderDelay = 0,
        $headerTextLeft = null,
        $headerTextCenter = null,
        $headerTextRight = null,
        $headerSize = 9,
        $headerFont = 'Courier',
        $headerFontSize = 11,
        $headerLine = false,
        $footerTextLeft = null,
        $footerTextCenter = null,
        $footerTextRight = null,
        $footerSize = 9,
        $footerFont = 'Courier',
        $footerFontSize = 11,
        $footerLine = false,
        $pageWidth = null,
        $pageHeight = null)

参数

参数 标签 描述
content 必需 HTML内容。这可以是加载HTML的URL或实际的HTML内容字符串
format 可选 默认值 输出格式,可用选项有:PDF、PNG、JPG
pageSize 可选 默认值 设置文档页面大小,可以是以下之一:A0 - A9,B0 - B10,Comm10E,DLE或Letter
title 可选 文档标题
margin 可选 默认值 文档边距(以毫米为单位)
marginLeft 可选 默认值 文档左侧边距(以毫米为单位)
marginRight 可选 默认值 文档右侧边距(以毫米为单位)
marginTop 可选 默认值 文档顶部边距(以毫米为单位)
marginBottom 可选 默认值 文档底部边距(以毫米为单位)
landscape 可选 默认值 设置文档为横向布局
zoom 可选 默认值 设置渲染页面时的缩放因子(2.0为双倍大小,0.5为半倍大小)
grayscale 可选 默认值 将最终文档渲染为灰度
mediaPrint 可选 默认值 使用@media print CSS样式渲染文档
mediaQueries 可选 默认值 在渲染前激活所有@media查询。如果您想渲染响应式网站的移动版本,这可能很有用
forms 可选 默认值 从HTML表单生成真实(可填写的)PDF表单
css 可选 将自定义CSS注入到HTML中。例如:'body { background-color: red;}'
imageWidth 可选 默认值 如果渲染为图像格式(PNG或JPG),则使用此图像宽度(以像素为单位)
imageHeight 可选 如果渲染为图像格式(PNG 或 JPG),请使用此图像高度(以像素为单位)。默认为自动,根据内容动态设置图像高度。
renderDelay 可选 默认值 在渲染页面之前等待的毫秒数(对于包含动画等的页面可能很有用)。
headerTextLeft 可选 打印到每页左侧页眉的文本。例如,'我的页眉 - 第 {page_number} 页,共 {total_pages} 页'。
headerTextCenter 可选 打印到每页中间页眉的文本。
headerTextRight 可选 打印到每页右侧页眉的文本。
headerSize 可选 默认值 页眉的高度(以毫米为单位)。
headerFont 可选 默认值 设置页眉字体。可用字体:Times、Courier、Helvetica、Arial。
headerFontSize 可选 默认值 设置页眉字体大小(以磅为单位)。
headerLine 可选 默认值 在页眉下方绘制全页宽的水平线。
footerTextLeft 可选 打印到每页左侧页脚的文本。例如,'我的页脚 - 第 {page_number} 页,共 {total_pages} 页'。
footerTextCenter 可选 打印到每页中间页眉的文本。
footerTextRight 可选 打印到每页右侧页眉的文本。
footerSize 可选 默认值 页脚的高度(以毫米为单位)。
footerFont 可选 默认值 设置页脚字体。可用字体:Times、Courier、Helvetica、Arial。
footerFontSize 可选 默认值 设置页脚字体大小(以磅为单位)。
footerLine 可选 默认值 在页脚上方绘制全页宽的水平线。
pageWidth 可选 显式设置 PDF 页面宽度(以毫米为单位)。
pageHeight 可选 显式设置 PDF 页面高度(以毫米为单位)。

示例用法

$content = 'content';
$format = 'PDF';
$pageSize = 'A4';
$title = 'title';
$margin = 0;
$marginLeft = 0;
$marginRight = 0;
$marginTop = 0;
$marginBottom = 0;
$landscape = false;
$zoom = 1;
$grayscale = false;
$mediaPrint = false;
$mediaQueries = false;
$forms = false;
$css = 'css';
$imageWidth = 1024;
$imageHeight = 110;
$renderDelay = 0;
$headerTextLeft = 'header-text-left';
$headerTextCenter = 'header-text-center';
$headerTextRight = 'header-text-right';
$headerSize = 9;
$headerFont = 'Courier';
$headerFontSize = 11;
$headerLine = false;
$footerTextLeft = 'footer-text-left';
$footerTextCenter = 'footer-text-center';
$footerTextRight = 'footer-text-right';
$footerSize = 9;
$footerFont = 'Courier';
$footerFontSize = 11;
$footerLine = false;
$pageWidth = 110;
$pageHeight = 110;

$result = $imaging->hTML5Render($content, $format, $pageSize, $title, $margin, $marginLeft, $marginRight, $marginTop, $marginBottom, $landscape, $zoom, $grayscale, $mediaPrint, $mediaQueries, $forms, $css, $imageWidth, $imageHeight, $renderDelay, $headerTextLeft, $headerTextCenter, $headerTextRight, $headerSize, $headerFont, $headerFontSize, $headerLine, $footerTextLeft, $footerTextCenter, $footerTextRight, $footerSize, $footerFont, $footerFontSize, $footerLine, $pageWidth, $pageHeight);

返回控制器列表

Class: Telephony

获取单例实例

可以从 API 客户端访问 Telephony 类的单例实例。

$telephony = $client->getTelephony();

Method: verifySecurityCode

检查来自验证 API 之一的验证码是否有效。见:https://www.neutrinoapi.com/api/verify-security-code/

function verifySecurityCode($securityCode)

参数

参数 标签 描述
securityCode 必需 要验证的验证码。

示例用法

$securityCode = 'security-code';

$result = $telephony->verifySecurityCode($securityCode);

Method: hLRLookup

连接到全球移动蜂窝网络并检索移动设备的状态。见:https://www.neutrinoapi.com/api/hlr-lookup/

function hLRLookup(
        $number,
        $countryCode = null)

参数

参数 标签 描述
number 必需 电话号码
countryCode 可选 ISO 2位国家代码,假设号码位于此国家。如果没有设置,则假设号码为国际格式(带或不带前导+号)

示例用法

$number = 'number';
$countryCode = 'country-code';

$result = $telephony->hLRLookup($number, $countryCode);

Method: phonePlayback

向任何有效的电话号码自动拨打电话并播放音频消息。见:[https://www.neutrinoapi.com/api/phone-playback/](https://www.neutrinoapi.com/api/phone-playback/)

function phonePlayback(
        $number,
        $audioUrl)

参数

参数 标签 描述
number 必需 要拨打的电话号码。必须为有效的国际格式
audioUrl 必需 有效音频文件的URL。接受的音频格式有
  • MP3
  • WAV
  • OGG
您可以使用以下MP3 URL进行测试:[https://www.neutrinoapi.com/test-files/test1.mp3](https://www.neutrinoapi.com/test-files/test1.mp3)

示例用法

$number = 'number';
$audioUrl = 'audio-url';

$result = $telephony->phonePlayback($number, $audioUrl);

Method: sMSVerify

通过短信向任何移动设备发送唯一的安全代码。见:[https://www.neutrinoapi.com/api/sms-verify/](https://www.neutrinoapi.com/api/sms-verify/)

function sMSVerify(
        $number,
        $codeLength = 5,
        $securityCode = null,
        $countryCode = null,
        $languageCode = 'en')

参数

参数 标签 描述
number 必需 发送验证码的电话号码
codeLength 可选 默认值 安全代码中使用的数字数量(必须介于4到12之间)
securityCode 可选 传入您自己的安全代码。如果您已实现TOTP或类似的双因素认证方法,则非常有用。如果没有设置,我们将生成一个安全的随机代码
countryCode 可选 ISO 2位国家代码,假设号码位于此国家。如果没有设置,则假设号码为国际格式(带或不带前导+号)
languageCode 可选 默认值 发送验证码的语言,可用语言有
  • de - 德语
  • en - 英语
  • es - 西班牙语
  • fr - 法语
  • it - 意大利语
  • pt - 葡萄牙语
  • ru - 俄语

示例用法

$number = 'number';
$codeLength = 5;
$securityCode = 110;
$countryCode = 'country-code';
$languageCode = 'en';

$result = $telephony->sMSVerify($number, $codeLength, $securityCode, $countryCode, $languageCode);

Method: sMSMessage

通过短信向任何移动设备发送自由格式消息。见:[https://www.neutrinoapi.com/api/sms-message/](https://www.neutrinoapi.com/api/sms-message/)

function sMSMessage(
        $number,
        $message,
        $countryCode = null)

参数

参数 标签 描述
number 必需 要发送消息的电话号码
消息 必需 要发送的短信消息。消息长度截断至最多150个字符(ASCII内容)或70个字符(UTF内容)
countryCode 可选 ISO 2位国家代码,假设号码位于此国家。如果没有设置,则假设号码为国际格式(带或不带前导+号)

示例用法

$number = 'number';
$message = 'message';
$countryCode = 'country-code';

$result = $telephony->sMSMessage($number, $message, $countryCode);

方法: phoneVerify

自动拨打任何有效的电话号码并播放唯一的验证码。见:[https://www.neutrinoapi.com/api/phone-verify/](https://www.neutrinoapi.com/api/phone-verify/)

function phoneVerify(
        $number,
        $codeLength = 6,
        $securityCode = null,
        $playbackDelay = 800,
        $countryCode = null,
        $languageCode = 'en')

参数

参数 标签 描述
number 必需 发送验证码的电话号码
codeLength 可选 默认值 安全码中使用的数字位数(4到12位之间)
securityCode 可选 传入您自己的安全代码。如果您已实现TOTP或类似的双因素认证方法,则非常有用。如果没有设置,我们将生成一个安全的随机代码
playbackDelay 可选 默认值 播放每个安全码之间的延迟(以毫秒为单位)
countryCode 可选 ISO 2位国家代码,假设号码位于此国家。如果没有设置,则假设号码为国际格式(带或不带前导+号)
languageCode 可选 默认值 播放验证码的语言,可用的语言有
  • de - 德语
  • en - 英语
  • es - 西班牙语
  • fr - 法语
  • it - 意大利语
  • pt - 葡萄牙语
  • ru - 俄语

示例用法

$number = 'number';
$codeLength = 6;
$securityCode = 110;
$playbackDelay = 800;
$countryCode = 'country-code';
$languageCode = 'en';

$result = $telephony->phoneVerify($number, $codeLength, $securityCode, $playbackDelay, $countryCode, $languageCode);

返回控制器列表

类: DataTools

获取单例实例

可以从API客户端访问DataTools类的单例实例。

$dataTools = $client->getDataTools();

方法: emailValidate

解析、验证并清理电子邮件地址。见:[https://www.neutrinoapi.com/api/email-validate/](https://www.neutrinoapi.com/api/email-validate/)

function emailValidate(
        $email,
        $fixTypos = false)

参数

参数 标签 描述
email 必需 一个电子邮件地址
fixTypos 可选 默认值 自动尝试修复地址中的拼写错误

示例用法

$email = 'email';
$fixTypos = false;

$result = $dataTools->emailValidate($email, $fixTypos);

方法: userAgentInfo

从用户代理字符串中解析、验证并获取详细用户代理信息。查看:https://www.neutrinoapi.com/api/user-agent-info/

function userAgentInfo($userAgent)

参数

参数 标签 描述
userAgent 必需 用户代理字符串

示例用法

$userAgent = 'user-agent';

$result = $dataTools->userAgentInfo($userAgent);

方法: badWordFilter

检测给定文本中的不良词汇、脏话和粗俗语言。查看:https://www.neutrinoapi.com/api/bad-word-filter/

function badWordFilter(
        $content,
        $censorCharacter = null)

参数

参数 标签 描述
content 必需 要扫描的内容。可以是加载内容的URL或实际的内容字符串
censorCharacter 可选 用于屏蔽找到的不良词汇的字符

示例用法

$content = 'content';
$censorCharacter = 'censor-character';

$result = $dataTools->badWordFilter($content, $censorCharacter);

方法: convert

一个强大的单位转换工具。查看:https://www.neutrinoapi.com/api/convert/

function convert(
        $fromValue,
        $fromType,
        $toType)

参数

参数 标签 描述
fromValue 必需 要转换的值(例如:10.95)
fromType 必需 要转换的值的类型(例如:USD)
toType 必需 要转换到的类型(例如:EUR)

示例用法

$fromValue = 'from-value';
$fromType = 'from-type';
$toType = 'to-type';

$result = $dataTools->convert($fromValue, $fromType, $toType);

方法: phoneValidate

解析、验证并获取电话号码的位置信息。查看:https://www.neutrinoapi.com/api/phone-validate/

function phoneValidate(
        $number,
        $countryCode = null,
        $ip = null)

参数

参数 标签 描述
number 必需 电话号码。可以是国际格式(E.164)或本地格式。如果传递本地格式,您还应该使用'country-code'或'ip'选项
countryCode 可选 ISO 2位国家代码,假设号码位于此国家。如果没有设置,则假设号码为国际格式(带或不带前导+号)
ip 可选 传入用户的IP地址,我们将假设号码属于IP地址所在的国

示例用法

$number = 'number';
$countryCode = 'country-code';
$ip = 'ip';

$result = $dataTools->phoneValidate($number, $countryCode, $ip);

返回控制器列表

类: SecurityAndNetworking

获取单例实例

可以通过API客户端访问SecurityAndNetworking类的单例实例。

$securityAndNetworking = $client->getSecurityAndNetworking();

方法: iPProbe

分析并提取IP地址的提供者信息。查看:[https://www.neutrinoapi.com/api/ip-probe/](https://www.neutrinoapi.com/api/ip-probe/)

function iPProbe($ip)

参数

参数 标签 描述
ip 必需 IPv4或IPv6地址

示例用法

$ip = 'ip';

$result = $securityAndNetworking->iPProbe($ip);

方法: emailVerify

基于SMTP的电子邮件地址验证。查看:[https://www.neutrinoapi.com/api/email-verify/](https://www.neutrinoapi.com/api/email-verify/)

function emailVerify(
        $email,
        $fixTypos = false)

参数

参数 标签 描述
email 必需 一个电子邮件地址
fixTypos 可选 默认值 自动尝试修复地址中的拼写错误

示例用法

$email = 'email';
$fixTypos = false;

$result = $securityAndNetworking->emailVerify($email, $fixTypos);

方法: iPBlocklist

IP黑名单API将检测潜在的恶意或危险IP地址。查看:[https://www.neutrinoapi.com/api/ip-blocklist/](https://www.neutrinoapi.com/api/ip-blocklist/)

function iPBlocklist($ip)

参数

参数 标签 描述
ip 必需 IPv4或IPv6地址

示例用法

$ip = 'ip';

$result = $securityAndNetworking->iPBlocklist($ip);

方法: hostReputation

检查IP地址、域名、FQDN或URL的信誉,与黑名单和阻止列表的全面列表进行比对。查看:[NeutrinoAPI 主机信誉 API](https://www.neutrinoapi.com/api/host-reputation/)

function hostReputation(
        $host,
        $listRating = 3)

参数

参数 标签 描述
host 必需 IP地址、域名、FQDN或URL。如果您提供域名/URL,它将与其他URI DNSBL列表进行比对
listRating 可选 默认值 仅检查具有此评级或更高评级的列表

示例用法

$host = 'host';
$listRating = 3;

$result = $securityAndNetworking->hostReputation($host, $listRating);

返回控制器列表

Class: 地理位置信息

获取单例实例

可以通过API客户端访问Geolocation类的单例实例。

$geolocation = $client->getGeolocation();

Method: geocodeReverse

将地理坐标(纬度和经度)转换为实际地址。查看:[NeutrinoAPI 地理编码反向 API](https://www.neutrinoapi.com/api/geocode-reverse/)

function geocodeReverse(
        $latitude,
        $longitude,
        $languageCode = 'en',
        $zoom = 'address')

参数

参数 标签 描述
latitude 必需 以十进制度数格式表示的位置纬度
longitude 必需 以十进制度数格式表示的位置经度
languageCode 可选 默认值 用于显示结果的显示语言,可用语言包括
  • de, en, es, fr, it, pt, ru
zoom 可选 默认值 响应的缩放级别
  • address - 可用最精确的地址
  • street - 街道级别
  • city - 城市级别
  • state - 州/省级别
  • country - 国家级别

示例用法

$latitude = 'latitude';
$longitude = 'longitude';
$languageCode = 'en';
$zoom = 'address';

$result = $geolocation->geocodeReverse($latitude, $longitude, $languageCode, $zoom);

Method: iPInfo

获取有关IP地址的位置信息并执行反向DNS(PTR)查找。查看:[NeutrinoAPI IP信息 API](https://www.neutrinoapi.com/api/ip-info/)

function iPInfo(
        $ip,
        $reverseLookup = false)

参数

参数 标签 描述
ip 必需 IPv4或IPv6地址
reverseLookup 可选 默认值 执行反向DNS(PTR)查找。此选项可能会增加请求的额外延迟,因此仅在需要时使用

示例用法

$ip = 'ip';
$reverseLookup = false;

$result = $geolocation->iPInfo($ip, $reverseLookup);

方法: geocodeAddress

将地址、部分地址或地点名称进行地理编码。参见:https://www.neutrinoapi.com/api/geocode-address/

function geocodeAddress(
        $address,
        $countryCode = null,
        $languageCode = 'en',
        $fuzzySearch = false)

参数

参数 标签 描述
address 必需 要尝试定位的地址、部分地址或地点名称
countryCode 可选 要偏好的ISO 2位字母国家代码(默认无国家偏好)
languageCode 可选 默认值 用于显示结果的显示语言,可用语言包括
  • de, en, es, fr, it, pt, ru
fuzzySearch 可选 默认值 如果给定地址没有找到匹配项,则开始执行递归模糊搜索,直到找到地理定位为止。此选项推荐用于处理用户输入或实现自动完成功能。我们使用近似字符串匹配和数据清洗的组合来找到可能的位置匹配项

示例用法

$address = 'address';
$countryCode = 'country-code';
$languageCode = 'en';
$fuzzySearch = false;

$result = $geolocation->geocodeAddress($address, $countryCode, $languageCode, $fuzzySearch);

返回控制器列表

类: ECommerce

获取单例实例

可以从API客户端访问ECommerce类的单例实例。

$eCommerce = $client->getECommerce();

方法: bINLookup

执行BIN(银行识别号码)或IIN(发行者识别号码)查找。参见:https://www.neutrinoapi.com/api/bin-lookup/

function bINLookup(
        $binNumber,
        $customerIp = null)

参数

参数 标签 描述
binNumber 必需 BIN或IIN号码(信用卡号码的前6位数字)
customerIp 可选 传入客户的IP地址,我们将返回有关他们的额外信息

示例用法

$binNumber = 'bin-number';
$customerIp = 'customer-ip';

$result = $eCommerce->bINLookup($binNumber, $customerIp);

返回控制器列表

类: WWW

获取单例实例

可以从API客户端访问WWW类的单例实例。

$wWW = $client->getWWW();

方法: uRLInfo

从提供的URL解析、分析和检索内容。请参阅:https://www.neutrinoapi.com/api/url-info/

function uRLInfo(
        $url,
        $fetchContent = false,
        $ignoreCertificateErrors = false,
        $timeout = 20)

参数

参数 标签 描述
url 必需 要检测的URL
fetchContent 可选 默认值 如果此URL响应html、text、json或xml,则返回响应。此选项很有用,如果您想对URL内容执行进一步处理(例如使用HTML Extract或HTML Clean API)
ignoreCertificateErrors 可选 默认值 忽略任何TLS/SSL证书错误并加载URL
timeout 可选 默认值 超时时间(秒)。如果在这么多秒后仍然尝试加载URL,则放弃

示例用法

$url = 'url';
$fetchContent = false;
$ignoreCertificateErrors = false;
$timeout = 20;

$result = $wWW->uRLInfo($url, $fetchContent, $ignoreCertificateErrors, $timeout);

方法: hTMLClean

清理和消毒不可信的HTML。请参阅:https://www.neutrinoapi.com/api/html-clean/

function hTMLClean(
        $content,
        $outputType)

参数

参数 标签 描述
content 必需 HTML内容。这可以是加载HTML的URL或实际的HTML内容字符串
outputType 必需 消毒级别,可能的值有:plain-text:将内容仅减少到纯文本(完全不包含HTML标签) simple-text:仅允许非常基本的文本格式化标签,如b、em、i、strong、u basic-html:允许高级文本格式化和超链接 basic-html-with-images:与基本HTML相同,但允许图像标签 advanced-html:与带有图像的基本HTML相同,但允许许多更多的常见HTML标签,如table、ul、dl、pre

示例用法

$content = 'content';
$outputType = 'output-type';

$result = $wWW->hTMLClean($content, $outputType);

方法: browserBot

浏览器机器人可以提取内容,与键盘和鼠标事件交互,并在网站上执行JavaScript。请参阅:https://www.neutrinoapi.com/api/browser-bot/

function browserBot(
        $url,
        $timeout = 30,
        $delay = 3,
        $selector = null,
        $exec = null,
        $userAgent = null,
        $ignoreCertificateErrors = false)

参数

参数 标签 描述
url 必需 要加载的URL
timeout 可选 默认值 超时时间(秒)。如果在这么多秒后仍然尝试加载页面,则放弃
delay 可选 默认值 在捕获任何页面数据、执行选择器或JavaScript之前等待的延迟时间(秒)
selector 可选 使用此选择器从页面DOM中提取内容。通常称为CSS选择器,您可以在这里找到一个很好的参考
exec 可选 集合 在页面上执行JavaScript。每个数组元素应包含一个有效的JavaScript语句(字符串形式)。如果一条语句返回任何类型的值,它将在“exec-results”响应中返回。为了您的方便,您还可以使用以下特殊快捷函数:sleep(seconds); 等待/暂停指定的时间(秒)。click('selector'); 点击第一个匹配给定选择器的元素。focus('selector'); 聚焦于第一个匹配给定选择器的元素。keys('characters'); 发送指定的键盘字符。使用click()或focus()首先发送键到特定元素。enter(); 发送Enter键。tab(); 发送Tab键。示例:[ "click('#button-id')", "sleep(1)", "click('.field-class')", "keys('1234')", "enter()" ]
userAgent 可选 用这个字符串覆盖浏览器默认的用户代理字符串
ignoreCertificateErrors 可选 默认值 忽略任何TLS/SSL证书错误,仍然加载页面

示例用法

$url = 'url';
$timeout = 30;
$delay = 3;
$selector = 'selector';
$exec = array('exec');
$userAgent = 'user-agent';
$ignoreCertificateErrors = false;

$result = $wWW->browserBot($url, $timeout, $delay, $selector, $exec, $userAgent, $ignoreCertificateErrors);

返回控制器列表