php - 相当于 file_get_contents ("php://input");在经典的asp中

标签 php asp-classic

是这个吗?

我正在尝试将 $data = file_get_contents("php://input"); 转换为经典 asp...

    Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0") 
    xmlhttp.open "GET", php://input, false 
    xmlhttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
    xmlhttp.send
    TOKEN = xmlhttp.responseText    

编辑:回答约翰的问题...

实时更新

Following a successful subscription, Facebook will proceed to call your endpoint every time that there are changes (to the chosen fields or connections). For each update, it will make an HTTP POST request.

The request will have content type of application/json and the body will comprise a JSON-encoded string containing one or more changes.

Note for PHP developers: In PHP, to get the encoded data you would use the following code:

$data = file_get_contents("php://input"); $json = json_decode($data);

最佳答案

编辑#2

这是根据您的 Facebook 信息进行的有根据的猜测 - 尝试一下

Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0") 
xmlhttp.open "GET", Request, false 
xmlhttp.setRequestHeader "Content-type", "application/json"
xmlhttp.send
TOKEN = xmlhttp.responseText

基本上,这是您最初的想法,在第 2 行和第 3 行中进行了一些更改。您也可以在第 2 行中尝试 Request.Form 而不是 Request,因为脚本正在接收 POST 数据

编辑 - 是的,看起来您的代码可以工作,只需进行一点小小的更改。您的网址需要放在双引号内 - 即

xmlhttp.open "GET", "php://input", false

谢谢你的提问。今天我学到了一些东西。我将保留我原来的答案作为背景阅读

您能告诉我更多有关您想要实现的目标吗?看起来您想要获取外部 URL 的内容,然后在 ASP 页面中使用它。如果外部 URL 的输出是有效的 XML,您当然可以使用 XML 对象。代码如下所示。

set xml = Server.CreateObject("Msxml2.DomDocument")
xml.setProperty "ServerHTTPRequest", true
xml.async = false
xml.validateOnParse = false
xml.load("http://yoururl")

然后您就有了一个 xml 对象,这里称为“xml”,您可以根据需要使用它。例如,如果您只想让它按原样显示在页面中,您可以添加

Response.write xml

如果您的外部 URL 输出不是有效的 XML,那么我认为经典 ASP 无法自行完成此操作,您可能需要在服务器上安装第三方组件,例如 AspTear

http://www.alphasierrapapa.com/ComponentCenter/AspTear/

您上面建议的代码或其变体可能很有效,我将对其进行实验。经典 ASP 本身已经有十多年没有更新了,但是 Microsoft 的 XML 处理器肯定已经更新了

关于php - 相当于 file_get_contents ("php://input");在经典的asp中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15440378/

相关文章:

PHP PDO语句过滤记录

mysql - 升级到 MySQL 5 后经典 ASP 中的类型不匹配

javascript - 将字符串转换为 boolean 值

php - 哪个操作系统更适合网络服务器,ubuntu 或 debian 或其他?

php - 在 php 中可以通过索引访问当前数组的元素吗?

php - 为什么 Eloquent\Builder 在 laravel 中不继承 Query\Builder?

xml - Asp XML 提要阅读器

UNC 共享 : is it problematic? 上的 IIS 站点

asp-classic - 基于ASP的网站和表单的错误处理

javascript - 如何将输入值分配给 jQuery 中的 url 参数?