Buy Now
Sign in

Web service REST and chronoforms implementation

johnli , August 27 2018, 19:21
J
johnli 17
August 27 2018, 19:21 #379870
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 7
August 27 2018, 22:17 #379871
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.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
J
johnli 17
August 28 2018, 08:47 #379874
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?
1.JPG
2.JPG
Attachments
1.JPG
1.JPG
(41.81 KiB)
156 Downloads/Views
2.JPG
2.JPG
(70.19 KiB)
177 Downloads/Views
1.JPG
1.JPG
(41.81 KiB)
160 Downloads/Views
2.JPG
2.JPG
(70.19 KiB)
166 Downloads/Views
2.JPG
2.JPG
(70.19 KiB)
168 Downloads/Views
1.JPG
1.JPG
(41.81 KiB)
152 Downloads/Views
healyhatman 7
August 28 2018, 12:14 #379878
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.
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store