DvideBy0
DvideBy0

Reputation: 688

PHP cross domain requests

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!

Upvotes: 0

Views: 7504

Answers (2)

Eduardo Reveles
Eduardo Reveles

Reputation: 2175

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.

Upvotes: 1

Igor Parra
Igor Parra

Reputation: 10348

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

Upvotes: 0

Related Questions