Posted 02 February 2013 - 17:26
Posted 02 February 2013 - 17:42
<?php session_start(); $_SESSION['post_data'] = $_POST; ?>
<?php session_start(); $_SESSION['post_data']/// Use this as the POST variable. ?>
<?php session_start(); $_SESSION['post_data']/// Use this as the POST variable. //After finishing the code: unset($_SESSION['post_data']); ?>
Posted 02 February 2013 - 17:43
$url = "https://www.formstack.com/forms/index.php"
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}Posted 02 February 2013 - 18:20
curl --data "param1=value1¶m2=value2" http://example.com/resource.cgi
Posted 02 February 2013 - 19:23
You've misunderstood, one of the two pages the OP wants to send the data to is on another web service!I did this by doing the following.
<snip>
One way you could perhaps find out: grab the POSTman addon for Google Chrome and use it to send a request. Set the method to POST, place your json encoded string in the body (RAW mode), and set the 'Content-Type' header to 'application/json', then see what you get back.I'll clarify a little bit. I'm sending the form data to https://www.formstac...forms/index.php
I don't think the Formstack API supports JSON.
This is the method I would suggest you use to do it, submitting to your own PHP script, then with that submitting to the other web service.I can quite easily get a webpage into a variable using php:
$url = "https://www.formstack.com/forms/index.php" function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); return $data; }
Now is it possible to somehow forward the $_POST data in the curl request so that I get the relevant data?
$data = json_encode($_POST);
$ch = curl_init('https://www.formstack.com/forms/index.php');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'
);
$result = curl_exec($ch);
$ch = curl_init('https://www.formstack.com/forms/index.php');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
This is interesting:
http://superuser.com...-a-post-requestcurl --data "param1=value1¶m2=value2" http://example.com/resource.cgi
No idea how to use this though.
Posted 04 February 2013 - 09:39
Thankfully though, there is no need to translate the $_POST array into an application/x-www-form-urlencoded string, you can simply give CURLOPT_POSTFIELDS an array, and it'll sort it out for you!
$ch = curl_init('https://www.formstack.com/forms/index.php'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch);