PHP跨域请求

发布于 2024-11-27 06:28:12 字数 675 浏览 0 评论 0原文

我是一个绿色程序员,最初是尝试用JS进行跨域请求。我很快了解到这是不允许的。与此处发布的类似问题不同,我想看看是否可以使用 PHP 来代替 JSONP 请求来制作它们。这可能吗?

简单的工作流程...

BROWSER: POST to my PHP the request-payload & request-headers

PHP: POST to Other Domain's URL the request-payload & request-headers

Other Domain: Process Request and send response

PHP: Send the Response-Content and Response-Header Info back to the browser

这是我正在尝试使用的 http://msdn.microsoft.com/en-us/library/bb969500%28v=office.12%29.aspx

我的目标是制作一个 Communicator Web访问基于网络且适合移动设备的客户端。

一个工作示例的链接就太棒了!

I am a green programmer and I was originally trying to make cross domain requests in JS. I quickly learned that this is not allowed. Unlike similar questions posted on here, I would like to see if I can use PHP to make them for me instead of JSONP requests. Is this possible?

Simple workflow...

BROWSER: POST to my PHP the request-payload & request-headers

PHP: POST to Other Domain's URL the request-payload & request-headers

Other Domain: Process Request and send response

PHP: Send the Response-Content and Response-Header Info back to the browser

Here is what I am trying to work with http://msdn.microsoft.com/en-us/library/bb969500%28v=office.12%29.aspx

My goal is to make a Communicator Web Access Client that is web based and mobile friendly.

A link to a working example would be awesome!

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

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

发布评论

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

评论(2

暗地喜欢 2024-12-04 06:28:12

在这种情况下,CURL 是您的选择,简单如下:

<?php
$ch = curl_init('http://otherdomain.com/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);

$result = curl_exec($ch);
var_dump($result);
?>

在这种情况下,$result 将包含站点的 html 代码。请注意,它不会像您在浏览器上访问该网站一样执行任何 JavaScript。

CURL yould be your option in this case, something simple as:

<?php
$ch = curl_init('http://otherdomain.com/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);

$result = curl_exec($ch);
var_dump($result);
?>

In this case, $result would contain the html code of the site. Please be aware that it doesn't going to execute any javascript as if you were visiting the site on the browser.

夏の忆 2024-12-04 06:28:12

您正在谈论网络服务,目标似乎是处理付款。任何主要的支付网关都有为此准备的 API。不管怎样,你可以自己学习。这是一个很好的起点 http://ajaxonomy.com/ 2008/xml/web-services-part-1-soap-vs-rest

You are talking about web services and seems that the goal is process payments. Any major payment gateway have APIs prepared for that. In any case you can study by your own. Here a good starting point http://ajaxonomy.com/2008/xml/web-services-part-1-soap-vs-rest

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文