Hi,
I need to connect the data we collect on a landing page and send it via cURL to the following code
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “http://www.bmby.com/shared/AddClient/index.php”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_REFERER, ‘http://xxxxxxxx/’);
$data = [
‘ProjectID’ => xxxx
‘Password’ => ‘xxxxxx’,
‘Fname’ => $_POST[‘your-name’],
‘Email’ => $_POST[‘email’],
‘Phone’ => $_POST[‘your-tel’],
#‘Esse’ => $_POST[‘msg’],
‘Referal’ => ‘http://xxxxxxxx/’,
‘MediaTitle’ => ‘אתר אינטרנט ראשי’,
‘AllowedMail’ => 2, # 0 = allow, 2 = don’t allow
‘IP’ => $_SERVER[‘REMOTE_ADDR’],
];
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
Any ideas how to do it.
I need help pleaseeeeeeee
Hey
Convertering that from PHP to Wix Code is not that hard. Do some reading on fetch command in Javascript. You will have to use the fetch and in that set the method to POST and set the body to your $data array.
let data = [
‘ProjectID’: “value here”
‘Password’: “value here”,
];
just remember to use JSON.stringify(data) before sending it and you will get back the results. There are plenty of good samples here in the forums and articles on how to use fetch in Wix Code.
I’m having a similar issue. I tried converting this CURL but its not working:
CURL
curl -X POST --header “Content-Type: application/json” --header “Accept: application/json” --header “Authorization: Bearer U0pDMh2NTJIZnc” -d “{"from":{"phoneNumber":"+13133982886"},"to":[{"phoneNumber":"+15555555555"}],"text":"Test 3 from RingCentral"}” “https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/sms”
CONVERSION
const url = ‘https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/sms’;
// The data we are going to send in our request
let data = {
from: {phoneNumber: ‘+13133982886’},
to: {phoneNumber: ‘+15555555555’},
text: ‘Test - Hi from website’
};
JSON.stringify(data);
// The parameters we are gonna pass to the fetch function
let fetchData = {
method: ‘POST’,
body: data
};
fetch(url, fetchData)
.then(function() {
// Handle response you get from the server
(json => console.log(json.id))
.catch(err => console.log(err));
});
Hey
Try this
let data = {
from: ‘+13133982886’,
to: ‘+15555555555’,
text: ‘Test - Hi from website’
};