什么是服务器到服务器发布脚本?

发布于 2024-08-18 19:26:45 字数 489 浏览 7 评论 0 原文

我正在将第三方模块集成到我的网站中。我阅读了他们的文档,但我坚持这一行:

“然后,您的脚本应该对我们的服务器进行服务器到服务器的发布。例如: https://www.domain.com:XXXX/gateway...”

这是什么?我用 POST 形式编写了一个 php 页面:

<form action"https://www.domain.com:XXXX/..." method="post">
...
<input type="submit">

是这样的吗?

然后做一个响应,假设他们发回“result=ok”,然后我捕获结果并检查结果是好还是失败?

我这样解释,我不知道我做的是否正确。有人可以建议吗?什么是服务器到服务器发布?

I am integrating a 3rd party module into my site. I read their documention, but I stuck at this line:

"Your script should then do a server-to-server posting to our server. For example: https://www.domain.com:XXXX/gateway..."

What is it? I write a php page with a POST-form:

<form action"https://www.domain.com:XXXX/..." method="post">
...
<input type="submit">

Is it something like that?

Then do a response, let say they send back "result=ok", then I catch the result and do a check whether the result is okay or failed?

I interpret in this way, I dont know if I am doing the correct thing. CAn anyone advice? What is the server-to-server posting?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤檠 2024-08-25 19:26:45

服务器到服务器的发布意味着在您的服务器上运行的程序向在供应商的服务器上运行的网关发出 HTTP POST。您提供的代码片段是 HTML。您需要有 PHP(或其他语言)的代码片段来执行 POST。 (如果您使用 JavaScript 执行此操作,则帖子将来自用户的 Web 浏览器,这不是您想要的。)

您想要使用 PHP HttpRequest 类。看一下 PHP 手册中的示例#2,转载于此处:

<?php
$r = new HttpRequest('http://example.com/form.php', HttpRequest::METH_POST);
$r->setOptions(array('cookies' => array('lang' => 'de')));
$r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t'));
$r->addPostFile('image', 'profile.jpg', 'image/jpeg');
try {
    echo $r->send()->getBody();
} catch (HttpException $ex) {
    echo $ex;
}
?>

A server-to-server posting means that the program running on your server makes an HTTP POST to a gateway running on the vendor's server. The code fragment that you provided is HTML. You will need to have a code fragment in PHP (or some other language) to execute the POST. (If you did it in JavaScript, the post will come from your user's web browser, which is not what you want.)

You want to use the PHP HttpRequest class. Take a look at Example #2 in the PHP Manual, reprinted here:

<?php
$r = new HttpRequest('http://example.com/form.php', HttpRequest::METH_POST);
$r->setOptions(array('cookies' => array('lang' => 'de')));
$r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t'));
$r->addPostFile('image', 'profile.jpg', 'image/jpeg');
try {
    echo $r->send()->getBody();
} catch (HttpException $ex) {
    echo $ex;
}
?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文