我目前正在使用Laravel构建Slack机器人,其中一个功能是它可以接收电子邮件地址并向其发送消息.
问题是电子邮件地址(例如bob@example.com)<mailto:bob@example.com|bob@example.com>来自Slack.
我目前有一个函数可以从中检索电子邮件:
public function getEmail($string)
{
$pattern = '/[a-z0-9_\-\+]+@[a-z0-9\-]+\.([a-z]{2,3})(?:\.[a-z]{2})?/i';
preg_match_all($pattern, $string, $matches);
$matches = array_filter($matches);
return $matches[0][0];
}
Run Code Online (Sandbox Code Playgroud)
这似乎与电子邮件地址一样正常工作bob@example.com,但是在使用电子邮件地址时似乎失败了bob.jones@example.com(<mailto:bob.jones@example.com|bob.jones@example.com>在这种情况下,函数将jones@example.com作为电子邮件地址返回.)
我对正则表达式不是很好,但是我可以使用/改变我的模式,还是从Slack提供的字符串中获取电子邮件地址的更好方法?
我对Vue很陌生,这将是我的第二个虚拟项目,旨在了解更多信息.
我目前有一个表单,我试图阻止表单提交,根据我可以做的文档v-on:submit.prevent.
我已将此添加到我的表单标签中,但在提交表单时,它仍然会通过并且根本没有被阻止.
我正在使用Vue版本2.1.3,以下是我到目前为止:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Node JS Server</title>
</head>
<body id="chat">
<form v-on:submit.prevent="send">
<input>
<button>Send</button>
</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.6.0/socket.io.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.3/vue.min.js"></script>
<script>
var socket = io();
new Vue({
el: '#chat',
methods: {
send: function(e) {
alert('Send method!');
}
}
})
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?从文档中我可以看出,表格不应该提交.
编辑
这里是代码中的小提琴
我的 Genymotion 有问题,它无法启动。
我总是收到这个错误:
三月 14 20:47:30 [Genymotion] [错误]“VirtualBox 仅主机以太网适配器 #2”:接口无效。子网:“169.254.41”掩码:“255.255.0.0” 三月 14 20:47:30 [Genymotion] [错误]“无法从 C:/Program Files/Genymobile/Genymotion/plugins/ 加载 vboxmanage 插件” 三月 14 20:47:30 [Genymotion] [错误] VM 引擎加载失败 三月 14 20:47:30 [Genymotion] [错误] 无法找到 VM 引擎。插件加载已中止。
在虚拟框中,每次 genymotion 启动后我都会获得新的仅主机适配器。
我尝试删除所有适配器以通过 genymotion 设置它们,为适配器设置 dhcp(192.168.56.100 ...),打开/关闭 Hyper-v,禁用防火墙和其他一些技巧。
我无法设置适配器的 IP,它始终设置为默认的 Microsoft 地址 169.254...
我的系统是 Windows 8.1,在 lenovo g510(i5、ati 显卡)上运行。Genymotion 2.4.0,VirtualBox 4.3.24。
有人有新鲜的建议吗?这让我疯狂 :/
感谢您的任何建议。
我以前从未编写过测试用例,并且正在尝试为我编写的 API 执行此操作。
我正在尝试使用 post 请求调用路由,因此我使用以下内容:
public function testRequestCorrectApiKey()
{
//Request with X-Authorization sending correct API Key
$response = $this->call('POST', '/authenticate', ['email' => 'testingphpunit@phpunittest.com', 'password' => 'phpunittest', [], [], ['X-Authorization' => '123workingapikey123']]);
$this->assertEquals(200, $response->status());
}
Run Code Online (Sandbox Code Playgroud)
这总是因错误而失败:
断言 404 匹配 200 失败
这自然表明它正在将请求发送到错误的路径。如何确保将其发布到正确的 URL 以及如何查看它试图访问的内容?
我已经尝试将我的.env文件中的 APP url 更新到http://localhost/gm-api/public我的config/app.php文件中。
我还更新了库存TestCase.php:
protected $baseUrl = 'http://localhost/gm-api/public';
Run Code Online (Sandbox Code Playgroud)
我哪里错了?
我已经在我的网络应用程序中为付款页面创建了一个模式,并希望显示付款提供商的品牌; 条纹.
默认情况下,图像为1950x927.我可以手动更改它,style但这不会使图像大小真正动态; 即它可能在桌面上看起来很好但仍然延伸到移动设备上的模态.
桌面:
移动:
如何使用模态响应加载图像大小?
以下是我页面上的代码:
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">How can you know your payment is secure?</h4>
</div>
<div class="modal-body">
<img src="{{ asset('img/stripe.png') }}" style="height:250px;">
<p>Stripe has been audited by a PCI-certified auditor and is certified to <a href="http://www.visa.com/splisting/searchGrsp.do?companyNameCriteria=stripe" target="_blank">PCI Service Provider Level 1</a>. This is the most stringent level of certification available in the payments industry. To accomplish this, they make use of best-in-class security tools …Run Code Online (Sandbox Code Playgroud) 我是Vue的新手,我正在尝试从API检索JSON响应,然后在我的页面上打印它.
这是我到目前为止:
<body>
<div id="mystats" class="container">
<h1>My Top Tracks</h1>
<ol>
<li v-for="track in tracks">@{{ track.name }}</li>
</ol>
<pre>@{{ tracks|json }}</pre>
<button v-on:click="fetchStats">Fetch stats</button>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.3/vue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-resource/1.0.3/vue-resource.min.js"></script>
<script type="text/javascript">
$vue = new Vue({
el: '#mystats',
data: {
tracks: [],
},
methods: {
fetchStats: function()
{
this.$http.get('/mystatsdata', {params: {type: 'tracks'}}).then((response) => {
this.tracks.push(response.body);
console.log(this.tracks.name);
}, (response) => {
// error callback
});
}
}
})
</script>
</body>
Run Code Online (Sandbox Code Playgroud)
以下是我要回复的回复:
[
[
{
"name": "Falling Away - Acoustic (Bonus Track)",
"track_number": 8, …Run Code Online (Sandbox Code Playgroud) 我对批处理脚本没有太多经验,我的雇主要求我编写一个批处理脚本,可以运行该脚本来查找和替换目录中所有匹配文件中的某些文本。
我尝试搜索此内容,并且有大量资源,我用这些资源到目前为止:
@echo off
setlocal enableextensions disabledelayedexpansion
set "search=<employeeloginid>0"
set "replace=<employeeloginid>"
set "textFile=TimeTEQ20170103T085714L.XML"
for /f "delims=" %%i in ('type "%textFile%" ^& break ^> "%textFile%" ') do (
set "line=%%i"
setlocal enabledelayedexpansion
set "line=!line:%search%=%replace%!"
>>"%textFile%" echo(!line!
endlocal
)
Run Code Online (Sandbox Code Playgroud)
这将找到所有出现的<employeeloginid>0并将其替换为集合文件<employeeloginid>中的内容- 在本例中。TimeTEQ20170103T085714L.XML
我现在需要调整它以在所有以以下开头 TimeTEQ和结尾的文件上运行 .xml
我发现这个答案显示了如何处理目录中的所有文件,但我不知道如何调整它以满足我的需要。
有人可以帮我吗?
我使用了“让我们加密”功能来允许我在服务器上设置SSL / HTTPS。
问题是我也运行了许多子域,这些都包括在初始安装中,但是现在回头看看-证书详细信息显示它是颁发给我的一个子域的。
我想将其更改为我的基本域,但是我不确定如何执行此操作。
我试过跑步 letsencrypt-auto --apache -d example.me -d www.example.me -d mysql.example.me
该过程已完成,但未更改任何内容,因为证书已经颁发。
我现在如何更改证书,或重新颁发证书,以便将其发布到我的基本域?
我最近刚刚开始在 Laravel 5.1 应用程序上使用 Sentry。
我在那里看到文档和入门资料,以及捕获用户信息的参考。
他们给出的传递这个的例子看起来像这样:
Raven.setUserContext({
email: 'foo@example.com'
});
Run Code Online (Sandbox Code Playgroud)
按照Laravel 的设置说明进行操作后,我没有看到任何有关此操作的参考信息,也没有看到文档中有关如何在配置文件或 Laravel 的任何内容中进行设置的任何参考信息。
关于如何设置它来发送用户信息有什么想法吗?用户在使用我的应用程序时将始终登录。
我正在构建一个基于Go bot的小命令行,它与Instagram API交互.
Instagram API是基于OAuth的,因此对于基于命令行的应用程序来说并不是太好.
为了解决这个问题,我在浏览器中打开了相应的授权URL,并使用本地服务器启动了重定向URI - 这样我可以捕获并优雅地显示访问令牌,而不是需要从中获取此权限的用户URL手动.
到目前为止,应用程序可以成功打开浏览器到授权URL,您授权它并将它重定向到本地HTTP服务器.
现在,在向用户显示访问令牌之后我不需要HTTP服务器,因此我想在执行此操作后手动关闭服务器.
为此,我从这个答案中汲取灵感并鼓励以下内容:
package main
import (
"fmt"
"io"
"log"
"net/http"
"os/exec"
"runtime"
"time"
)
var client_id = "my_client_id"
var client_secret = "my_client_secret"
var redirect_url = "http://localhost:8000/instagram/callback"
func main() {
srv := startHttpServer()
openbrowser(fmt.Sprintf("https://api.instagram.com/oauth/authorize/?client_id=%v&redirect_uri=%v&response_type=code", client_id, redirect_url))
// Backup to gracefully shutdown the server
time.Sleep(20 * time.Second)
if err := srv.Shutdown(nil); err != nil {
panic(err) // failure/timeout shutting down the server gracefully
}
}
func showTokenToUser(w http.ResponseWriter, r *http.Request, srv …Run Code Online (Sandbox Code Playgroud) laravel ×4
php ×3
javascript ×2
vue.js ×2
android ×1
apache ×1
batch-file ×1
cmd ×1
css ×1
genymotion ×1
go ×1
html ×1
httpserver ×1
laravel-5.1 ×1
laravel-5.2 ×1
laravel-5.3 ×1
lets-encrypt ×1
phpunit ×1
regex ×1
sentry ×1
slack-api ×1
ssl ×1
virtualbox ×1
windows ×1