我是php的新手。目前我正面临着关于php curl post和重定向的问题。我已经编写了大量代码来连接跨域api。在此API中,响应将把我的页面重定向到另一个页面。
所以,现在我面临的问题是,我也不能遵循api的响应。这意味着在我的php脚本中,我的curl已经收到了重定向页面的网页内容,但我的页面仍然存在。
我可以知道php curl可以跟随API重定向吗?
有没有人知道如何解决这个问题?
下面是我的代码。
$url = "http://www.google.com.my"; //example this is an API
$ch = curl_init();
curl_
我有两个PHP文件,一个用于“繁重提升”,一个用于快速响应,用于将请求编组到重提升器,以便快速响应文件可以立即响应服务器请求(至少这是目标)。这样做的前提是Slash命令,它们更喜欢即时200来让用户知道命令正在运行。
<?php
echo("I want this text to reply to server instantly");
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$code =
我的目标是向服务器发送一个POST请求并得到适当的响应。
注:角括号表示占位符。
在终端中,使用以下代码将为我提供所需的响应。
curl -u <user>:<pass> -H 'Content-Type: application/xml' -X POST https://<rest of url>
我当前的PHP如下所示:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $uri); //$uri is the same that I use in terminal
curl_setopt(