- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将 Tierion Hash API 与 PHP 集成,但我是初学者,不知道如何开始...
但是我不明白,我该如何进行POST请求?我可以在哪里写这个? {
“用户名”:“xxxxx”,“密码”:“xxxx”}
}
最佳答案
汤姆来自Tierion这里。使用 HashAPI,您需要首先提交您的帐户凭据以获取临时访问 token 。该访问 token 是您将通过哈希的 POST 请求提交给 HashAPI 的内容,从而对提交进行身份验证。我将使用 Hash API 和无 CURL PHP 实现来介绍一些主要请求:
1) 通过提交您的凭据作为参数,通过/token/端点获取访问 token 和刷新 token 。
首先,您必须将您的用户名和密码作为请求参数提交到我们的/token/端点以获取您的访问 token 。您的凭据作为参数发送,而不是作为请求 header 发送。
代码:
// Specify your request URL and the parameters you need to send.
$url = 'https://hashapi.tierion.com/v1/auth/token';
$data = array('username' => '_YOUR_USERNAME_', 'password' => '_YOUR_PASSWORD_');
// Use the "HTTP" key even if you're making an HTTPS request.
$options = array(
'http' => array(
'method' => 'POST',
'content' => http_build_query($data)
)
);
// Create and submit the HTTP request.
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Check for a failed request, handle error according.
if ($response === FALSE) {
// Handle error
}
// $response now holds your authorization token, expiration time, and refresh token.
var_dump($response);
响应示例:
{
"access_token": "eyB9eXAiOiJKV1QiLDJhbGciOiJIUzI1NiJ8.eyJpZCI6IjU2ZyyiYzFhNWY5Yjg1MjMyZmRjYWRhNyIsInJsbiI6MjBwMCwicmxpIjoicyIsImlzQWRtaW4iOnRydWUtImlhdCI6MTQ2MTI0NzE2NSwiZXhwIjoxNDYxMjUwNzY1LCJqdGkiOiI1MDUyYmFlZDhkNTM5NjcyNDNiMjkzN2RjNjRjNTcyOTJmNTQwZDZhIn0.KNiG-QHdeaH1jVLJpx0ykov8Kk7ogts69k5OhDkgFVM",
"expires_in": 3600,
"refresh_token": "ec71236f77ebd665210912ae8891aa08ee8ec3e4"
}
2) 通过/refresh/端点获取更新的访问 token ,将刷新 token 作为参数提交。
您的访问 token 的有效期为一小时,之后需要刷新。您需要将收到的刷新 token 和授权 token 一起提交到我们的/refresh/端点。您将获得一个新的授权 token ,该 token 将在另外一个小时内有效。您的访问 token 将作为参数而不是请求 header 发送。
代码:
// Specify your request URL and the parameters you need to send.
$url = 'https://hashapi.tierion.com/v1/auth/refresh';
$data = array('refreshToken' => '_YOUR_VALID_REFRESH_TOKEN_');
// Use the "HTTP" key even if you're making an HTTPS request.
$options = array(
'http' => array(
'method' => 'POST',
'content' => http_build_query($data)
)
);
// Create and submit the HTTP request.
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Check for a failed request, handle error according.
if ($response === FALSE) {
// Handle error
}
// $response now holds your NEW authorization token, expiration time, and refresh token.
var_dump($response);
响应示例:
{
"access_token": "eyoJAxeiOiJKV1QiLCJhbGciOiIUJzI1NiJ9.eyJpZCI6IjU2ZWRiYzFhNWY5Yjg1jMjyZmRjYWRhNyIsInJsbiI6MjAwMCwicmxpIjoicyIsImlzQWRtaW4iOnRydWUsImlhdCI6MTQ2MTI0Nzk5NCwiZXhwIjoxNDYxMjUxNTk0LJCqdGkiOiIyM2M5NjVjMTYwNzM3NWZlMzQ0MWFiNDFjZTZjM2JkODkzODYxNWRiIn0.qFKIpT5q4K0u1P8_jwUsQkxxcCGu3uGsQKi33c-1gEM",
"expires_in": 3600,
"refresh_token": "ec32176f77ebd556210912ae8891aa08ff8ec3e4"
}
3) 将您的哈希值提交到哈希 API,并使用您的授权 token 作为请求中的 header 。
现在您已经有了访问 token ,您可以将哈希值提交到哈希 API。您需要使用您的哈希值作为请求参数,并将您的授权 token 作为请求 header 来发出请求。
代码:
// Specify your request URL and the parameters you need to send.
$url = 'https://hashapi.tierion.com/v1/hashitems';
$data = array('hash' => '_YOUR_SHA256_HASH_');
// Use the "HTTP" key even if you're making an HTTPS request.
$options = array(
'http' => array(
'header' => "Authorization: Bearer _YOUR_VALID_ACCESS_TOKEN_",
'method' => 'POST',
'content' => http_build_query($data)
)
);
// Create and submit the HTTP request.
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Check for a failed request, handle error according.
if ($response === FALSE) {
// Handle error
}
// $response now holds your blockchain receipt ID and timestamp.
var_dump($response);
响应示例:
{
"receiptId": "571694dd6b5c7b711861ea67",
"timestamp": 1461097693
}
4) 接收带有receiptId的对应区 block 链收据。
发送哈希值后,您将收到一个receiptId。此 ID 是 Tierion 系统中指向您的区 block 链收据的唯一指针。该 ID 与区 block 链本身无关,但与收据相关。要获取收据,您可以将receiptId发送到我们的/receipts/端点。
您将receiptId附加到请求URL的末尾,而不是通过请求参数发送它。
代码:
// Specify your request URL and the parameters you need to send.
$url = 'https://hashapi.tierion.com/v1/receipts' + _YOUR_RECEIPT_ID_;
// Use the "HTTP" key even if you're making an HTTPS request.
$options = array(
'http' => array(
'header' => "Authorization: Bearer _YOUR_VALID_ACCESS_TOKEN_",
'method' => 'POST',
)
);
// Create and submit the HTTP request.
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Check for a failed request, handle error according.
if ($response === FALSE) {
// Handle error
}
// $response now holds your blockchain receipt.
var_dump($response);
响应示例:
{
"receipt": "{\"@context\":\"https://w3id.org/chainpoint/v2\",\"type\":\"ChainpointSHA256v2\",\"targetHash\":\"a83a2c5c11a2bc814d0b1dca0a385d71a1f4d662b4e31335ba7562c56cce15b1\",\"merkleRoot\":\"2d21167d2f2f73e309d5ac00ab9faaf8b530478c5b64dcd5755511c8a3eccfa3\",\"proof\":[{\"left\":\"7c6e3b0159f1359d0f9f5a3b923011b7466bdf1423317ca09121b5dc61ad1836\"},{\"right\":\"541c5ae04e83c2880296818978511893ba1b00f1515162cd865f25da54f636d0\"},{\"right\":\"67b7ced55a4db4bb0fbaf2036901888a08ab7d8126556431258017652cf62092\"}],\"anchors\":[{\"type\":\"BTCOpReturn\",\"sourceId\":\"33884d525ca1cc54313fa2f27be4cf3442b35314866851cc7fc5ec3973d80250\"}]}"
}
如果您有任何其他问题,请随时联系我们的团队: [email protected] 或查看我们的 Hash API documentation 。答案here提供有关 PHP HTTP 请求的更多信息。
关于php - 如何集成Tierion Hash API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39036811/
Windows 集成 (NTLM) 身份验证和 Windows 集成 (Kerberos) 之间有什么区别? 如何在IIS6中实现这些 w.r.t. MSDN 最佳答案 Kerberos 和 NTLM
Keycloak是一个用 Java 编写的开源身份验证和身份管理解决方案。它提供了一个nodejs适配器,使用它我能够成功地与express集成。这是有效的路由文件: 'use strict'
这是我关于 Bamboo 的第二个问题 ( My First One )。阅读建议信息后我的理解是,我需要一个构建工具,例如 nAnt 或 MSbuild 来编写一个获取源代码并构建它的脚本(我正在开
可用于将第三方应用程序与 jira 4.3 集成的身份验证方案有哪些?显然,从客户那里获取用户名和密码听起来很荒谬。另外,我知道 oauth 身份验证仅适用于版本 5。请告诉我。谢谢。 附注。我不是在
我有一个使用 DDS 的旧版 C++ 应用程序用于异步通信/消息传递。我需要将此应用程序集成到使用 JMS 进行消息传递的 JavaEE 环境中。除了构建独立的 JMS/DDS 桥接模块之外,我还有其
我正在尝试使用 Whatsapp 发送测试消息,但收到此错误消息: "error":{"code":27,"description":"Recipient not available on chann
我想将 photologue 与我的 Django 应用程序集成,并使用它在车辆库存中显示照片......有点像 Boost Motor Group Inc. 提供的内容。我已经集成了该应用程序,所以
我目前正在尝试弄清楚如何与 fujitsu scansnap 扫描仪集成,但没有从 fujitsu 找到有关 fujitsu scansnap 管理器如何调用您的应用程序并将文件发送到您的应用程序的详
在我的项目中,我使用了 9 个(九个)int-ip:udp-inbound-channel-adapter 和一个 jms:inbound-channel-adapter。 Jms 适配器从服务器接收
在我们当前的原型(prototype)中,大多数标准 HTML 控件都被小程序取代,最重要的是表单提交由小程序触发。 有没有一种方法可以像 一样在服务器端调用关联的操作 ? 本文Applet and
是否可以使用 twilio 号码从 whatsapp 发送/接收短信?有人用whatsapp试过twilio吗?我问过客服,如果可能的话,他说,不确定,但很多人都问过这个问题。 最佳答案 万一其他人来
我们办公室中几乎不存在版本控制,这显然导致了很多麻烦。我们想使用SVN和Notepad++进行设置...任何人都对如何实现此目标有任何想法?我已经开始研究并浏览了这个网站: http://www.sw
曾经有提供这种集成的 spring-modules 项目;但是,该项目现已弃用。现在有没有人继续支持这种集成?谢谢。 最佳答案 工作正在进行中。 http://blog.athico.com/sear
我的理解是,根据 http://wiki.dbpedia.org/Datasets,DBpedia 从 YAGO 获取类层次结构,而不是实体。 .但是,类似 http://dbpedia.org/cl
任何人都可以帮助我如何将 OpenCMS 与 Java Spring Web 应用程序集成。已经用谷歌搜索并浏览了很多网站但没有用。所以,请帮助我。 最佳答案 我认为将 SpringMVC 与 Ope
我正在尝试使用新的 migs getaway (MPGS) 我遵循了下一个 url 中的代码 https://ap-gateway.mastercard.com/api/documentation/i
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve thi
我有一个 cmake 项目。我想轻松完成以下操作 搜索光标下任何变量、函数等的声明、定义和引用,这些可能在外部头文件中声明,其路径是在CMakeLists.txt中使用INCLUDE_DIRECTOR
有人能给我指点一下 Objective-C(或 c/c++)库的方向,或者教通过 FTP 上传或下载的教程(Objective-C)吗?最好能展示如何将文件下载到临时目录,然后稍后上传?我不介意针对
集成()给出了非常错误的答案: integrate(function (x) dnorm(x, -5, 0.07), -Inf, Inf, subdivisions = 10000L) # 2.127
我是一名优秀的程序员,十分优秀!