我构建了一些通过 webhook 向 Microsoft Teams 发送消息的工具,我决定切换到自适应卡,以使发送的消息更易于阅读和布局,因为自适应卡可以比标准卡更加风格化MessageCard (0365 Connector)我已经成功实现了这一目标,但不幸的是在终点线遇到了一些障碍。
当使用自适应卡发送推送通知时,它不会给出简短的细分或消息的前几行,而是简单地说Card。它也在 Microsoft Teams(PC 或移动)的“通知”选项卡下以这种方式显示,因此您可以想象这有点令人恼火,因为我发送了很多消息,而您需要实际点击/单击才能阅读它们,而无需提前看一下总结。
在旧式/O365 连接器中,我只需使用该summary字段即可正常工作。
//O365 Connector
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"summary": "John Doe commented on Trello",
"title": "Project Tango",
Run Code Online (Sandbox Code Playgroud)
我已经看到以下内容作为 Bot 框架的建议:
var response = MessageFactory.Text(string.Empty);
response.Attachments.Add(cardAttachment);
response.Summary = "showing custom greeeting from the Bot - rather than a card";
await turnContext.SendActivityAsync(response, cancellationToken);
Run Code Online (Sandbox Code Playgroud)
但这并不适用于此,因为我使用的是 webhooks...但我尝试将其Summary作为有效负载中的键来查看它是否有帮助,但没有。
我查看了 Adaptive-card.json 架构,但我看不到其中任何看起来会影响 toast/推送通知的内容。我确实尝试过,fallbackText但我认为这只在渲染器无法加载自适应卡的情况下使用,并且根本不用于摘要。
有任何想法吗?或者使用自适应卡是否意味着我需要牺牲在通知/祝酒词中总结信息的能力?
我有一个SelectInput让我选择 1、2 或 3 的选项,在它下面,我有一个MultiSelect(带有 Mantine 库)。
我想选择副驾驶的数量(在 上SelectInput),并允许在 上选择所选的数量MultiSelect。
这是我的代码:
const [maxCopilote, setMaxCopilote] = useState()
<NumberInput
defaultValue={1}
max={3}
min={1}
required
placeholder="Number of copilot"
onChange={(e) => setMaxCopilote(e)}
/>
<MultiSelect
data={['Copilote1', 'Copilote2', 'Copilote3']}
required
placeholder="Select copilote(s)"
maxSelectedValues={maxCopilote}
clearable
/>
Run Code Online (Sandbox Code Playgroud)
使用这段代码,我得到了错误:
Argument of type 'number | undefined' is not assignable to parameter of type SetStateAction<undefined>.
Type 'number' is not assignable to type 'SetStateAction<undefined>'. TS2345
Run Code Online (Sandbox Code Playgroud)
如何获取我选择的数字,并将其动态放入maxSelectValues?
谢谢
PS:console.log(e)onChange中的numberInput,正确记录选择的号码
我正在尝试将我的 Clerk 数据同步到 Next js 13 项目中的数据库。我的 webhooks 通过 Ngrok 公开暴露。这是我的代码:
import { IncomingHttpHeaders } from "http";
import { headers } from "next/headers";
import { NextResponse } from "next/server";
import { Webhook, WebhookRequiredHeaders } from "svix";
const webhookSecret = process.env.WEBHOOK_SECRET || "";
async function handler(request: Request) {
console.log(await request.json())
const payload = await request.json();
const headersList = headers();
const heads = {
"svix-id": headersList.get("svix-id"),
"svix-timestamp": headersList.get("svix-timestamp"),
"svix-signature": headersList.get("svix-signature"),
};
const wh = new Webhook(webhookSecret);
let evt: Event | null = …Run Code Online (Sandbox Code Playgroud) Shopify提供Ruby和PHP中的示例来实现此目的.在我的节点/快递应用程序中,我尝试:
var data = querystring.stringify(req.body);
var calculatedSha256 = crypto.createHmac("SHA256", APP_SECRET).update(new Buffer(data, 'utf8')).digest('base64');
Run Code Online (Sandbox Code Playgroud)
并且
var data = req.body;
var calculatedSha256 = crypto.createHmac("SHA256", APP_SECRET).update(new Buffer(data, 'utf8')).digest('base64');
Run Code Online (Sandbox Code Playgroud)
但是它们都没有提供与Shopify作为签名发送的字符串相同的字符串.
我正在设置Stripe的webhook.基本上是因为它是一个订阅模式,我需要知道我是否会继续更新月份.我想通过'invoice.payment_succeeded'活动来做到这一点.
当我用条纹测试我的webhook网址时,我得到了这个:
host localhost:3000 resolves to illegal IP 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
我的完整终点是:
localhost:3000/hooks/receiver
Run Code Online (Sandbox Code Playgroud)
路线:
get 'hooks/receiver' => "hooks#receiver"
Run Code Online (Sandbox Code Playgroud)
钩子控制器看起来像这样:
class HooksController < ApplicationController
require 'json'
Stripe.api_key
def receiver
data_json = JSON.parse request.body.read
p data_json['data']['object']['customer']
if data_json[:type] == 'invoice.payment_succeded'
make_active(data_event)
end
if data_json[:type] == 'invoice.payment_failed'
# something make_inactive(data_event)
end
end
def make_active(data_event)
@user = User.find_by_customer_token(data['data']['object']['customer'])
@status = @user.statuses.pluck(:list_id).presence || -1
Resque.enqueue(ScheduleTweets, @user.token, @user.id, @status)
end
def make_inactive(data_event)
end
end
Run Code Online (Sandbox Code Playgroud)
有人知道如何解决这个问题吗?
我想处理数据,这是由trello webhook发出的.有webhook帖子到网站,如site.com/tracker.php
在tracker.php中,我想将数据保存在数据库中.为此,我需要得到一些参数.
这是我收到的代码示例(https://trello.com/docs/gettingstarted/webhooks.html):
{
"action": {
"id":"51f9424bcd6e040f3c002412",
"idMemberCreator":"4fc78a59a885233f4b349bd9",
"data": {
"board": {
"name":"Trello Development",
"id":"4d5ea62fd76aa1136000000c"
},
"card": {
"idShort":1458,
"name":"Webhooks",
"id":"51a79e72dbb7e23c7c003778"
},
"voted":true
},
"type":"voteOnCard",
"date":"2013-07-31T16:58:51.949Z",
"memberCreator": {
"id":"4fc78a59a885233f4b349bd9",
"avatarHash":"2da34d23b5f1ac1a20e2a01157bfa9fe",
"fullName":"Doug Patti",
"initials":"DP",
"username":"doug"
}
},
"model": {
"id":"4d5ea62fd76aa1136000000c",
"name":"Trello Development",
"desc":"Trello board used by the Trello team to track work on Trello. How meta!\n\nThe development of the Trello API is being tracked at https://trello.com/api\n\nThe development of Trello Mobile applications is being tracked at https://trello.com/mobile",
"closed":false,
"idOrganization":"4e1452614e4b8698470000e0", …Run Code Online (Sandbox Code Playgroud) 我从一个woocommerce网站收到webhooks到nodejs/express应用程序.我试图验证webhook的签名以证明真实性,但我计算的哈希永远不会对应于woocommerce在钩子的签名头中报告的签名.
这是我用来验证真实性的代码:
function verifySignature(signature, payload, key){
var computedSignature = crypto.createHmac("sha256", key).update(payload).digest('base64');
debug('computed signature: %s', computedSignature);
return computedSignature === signature;
}
Run Code Online (Sandbox Code Playgroud)
使用以下参数调用此函数:
var signature = req.headers['x-wc-webhook-signature'];
verifySignature(signature, JSON.stringify(req.body), config.wooCommence.accounts.api[config.env].webhookSecret)
Run Code Online (Sandbox Code Playgroud)
webhook的签名标题将签名报告为BewIV/zZMbmuJkHaUwaQxjX8yR6jRktPZQN9j2+67Oo=.然而,上述操作的结果是S34YqftH1R8F4uH4Ya2BSM1rn0H9NiqEA2Nr7W1CWZs=
我已经在webhook上手动配置了秘密,正如您在上面的代码中所看到的,这个相同的秘密也在快速应用程序中进行了硬编码.因此,要么我正在使用错误的有效负载来计算签名,要么还有其他可疑的东西阻止我验证这些签名.
非常感谢帮助我解决这个问题的任何指示.
我可以使用curl发布到我的Slack Incoming Webhook:
curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello world"}' https://hooks.slack.com/services/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
Run Code Online (Sandbox Code Playgroud)
但是当我使用时
$.ajax({
url: "https://hooks.slack.com/services/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",
data: '{"text": "Hello world"}',
type: "POST",
contentType: "application/json"
})
.done(function (reply) {
console.log("POST to Slack succeeded")
})
.fail(function (xhr, status, errorThrown) {
console.log("Error in POST to Slack: " + errorThrown.toString())
})
Run Code Online (Sandbox Code Playgroud)
在我的应用程序的localhost:8090服务的页面中,我收到错误:
jquery.js:9536 OPTIONS https://hooks.slack.com/services/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
400 (Bad Request)
XMLHttpRequest cannot load https://hooks.slack.com/services/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.
Response for preflight has invalid HTTP status code 400
Run Code Online (Sandbox Code Playgroud)
通常,我页面上的POST将转到我的服务器,该服务器为页面提供服务.所以我认为我的困惑与理解Webhooks如何工作有关.我认为同源政策禁止我发布到任意网址.但是为什么curl命令工作,我如何让我的页面做curl的工作呢?
我是否需要从服务器发送POST,而不是从客户端浏览器发送?
有没有办法在ASP.NET Core中创建Webhooks?
我查看了https://github.com/aspnet/WebHooks,但我找不到对ASP.NET Core的支持
我正在使用Ruby on Rails 5和ruby -v 2.5.3。我正在尝试验证一个Webhook,示例显示:
require 'base64'
require 'php_serialize'
require 'openssl'
public_key = '-----BEGIN PUBLIC KEY-----
MIICIjANBgkqh...'
# 'data' represents all of the POST fields sent with the request.
# Get the p_signature parameter & base64 decode it.
signature = Base64.decode64(data['p_signature'])
# Remove the p_signature parameter
data.delete('p_signature')
# Ensure all the data fields are strings
data.each {|key, value|data[key] = String(value)}
# Sort the data
data_sorted = data.sort_by{|key, value| key}
# and serialize the fields
# serialization library is …Run Code Online (Sandbox Code Playgroud)