我正在尝试让我的控制器运行我自己的powershell脚本,该脚本向我们的microsoft teams channel发布消息,但我无法让它工作。 当我自己运行这个脚本时,它工作得很好,并且在microsoft团队中发布了一条消息,但是我不能让laravel运行它。 已经找了好几个小时了。 尝试了一些作曲家包,但似乎不能得到任何工作。
在PlanningController.php中,我得到了:
public function test(){
echo exec('whoami');
}
当我运行它时,我会得到返回的用户名,正如您所期望的,但是我不知道如何切换它,所以它运行我自己的脚本。 有没有更简单的方法来做这件事?
我正在尝试运行的test.ps1 powershell脚本:
Invoke-RestMethod -Method post -ContentType 'Application/Json' -Body ' {
"@type": "MessageCard",
"@context": "https://schema.org/extensions",
"summary": "Office 365 Notification",
"themeColor": "0072C6",
"title": "Insert title here",
"sections": [
{
"facts": [
{
"name": "Item name:",
"value": "ID"
},
{
"name": "Start time:",
"value": "DATETIME"
},
{
"name": "Service:",
"value": "SERVICENAME"
},
{
"name": "Description:",
"value": "Insert message description here"
}
],
"text": "Insert message text here"
}
]
}' -Uri <MY-WEBHOOK-URL-HERE>
这是我第一次在这里发帖,所以我希望我没有错过任何重要的东西。 谢啦!
我用这个方法解决了这个问题:
https://github.com/sebbmeyer/laravel-teams-connector