Forums

Web service REST and chronoforms implementation

johnli 27 Aug, 2018
Hello,
I have a website and I wish the connected to the web service that a friend has developed using Laravel.
The problem is that I am not a good developer, and my challenge for now is to be able to consume the address his_domain / API / service he spun me.
I did research and I saw some articles that deal with the subject but nothing concrete. However, I chose the method I saw here on this forum.
Here is à part of code that I add in the custom code of my form but I have no results.
<?php
# An HTTP GET request example
$url = 'http://192.168.100.34/mobility-v2_dev2/public/api/service';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
echo $data;
?>

An idea of what needs to be changed?

Thank in advance
healyhatman 27 Aug, 2018
The url, unless your friend is running the web server on your computer. Also try
print_r($data);
instead of echo to check for data. If you have the "return as var" option selected, things won't actually echo but will be stored in the var, so make sure that's not checked.
johnli 28 Aug, 2018

print_r($data);


is not work.

If you have the "return as var" option selected


Please, how can I do to check "return as var" option selected?

I inspected the code of the page and the PHP part is in comment. (see images)

Is this normal?

healyhatman 28 Aug, 2018
OK sorry I thought you were in CF6, ignore my "return as var" comment.

I'm not familiar with CF5 but clearly your PHP code is in the wrong spot since it's just being put in your form as a html comment - no, it's not normal.

You'll have to read the manual or FAQs or wait for Bob or someone else to help you sorry, don't know anything about CF5.
This topic is locked and no more replies can be posted.