Forums

Curl Action and Sms Http

karalismak 19 May, 2012
Hi everyone,
First of all I would like to thanks Chronoforms for their excellent work.
I am making my first web site and I have found Chronoforms very helpful.
But,I have problem with curl plugin action. I use Chronoforms_V4.

In my form, there are 3 text boxes (name,phone and date)and the submit button.
I want to make the form sending sms with the above three values (name,phone and date) in a mobile phone (constant value) when somebody submitting the form.

The code for SMS HTTP API from the sms company is:
In order to send an SMS you must make a GET request of the following URL:
https://bu..../api/http/send.php


The parameters of this request are:
username (required) The user name
password (required) The user’s password
from (required) The sender identity of the message
to (required) The message recipients, comma delimited without spaces
message (optional) The text message
All the above parameters have to be url encoded.

In the Curl action in the target URL I write:
https://bu..../api/http/send.php?username=xxx&password=xxx&from=xxx&to=12345678&message={name}+{phone}+{date}


and in the Params/Fields map:
name={name}
phone={phone}
date={date}


The problem is that the text of the sms that comes in the mobile phone is : {name}+{phone}+{date} and not the value from the form.
I have tried a lot of times in different ways but i can't find how to make the message of the sms load the value from the form.

Thanks in advance
GreyHead 20 May, 2012
Hi karalismak,

Please see this article from The ChronoForms Book. It was written for CFv3 but most of the content still applies in CFv4 except that the layout of the action is a little different to the layout of the CFv3 plug-in.

The main change you need to make it to limit the Target URL to the part before the ?

Bob
karalismak 23 May, 2012
Thank for your answer.

I have tried so many times but i still can't figure out how to fill the curl target and the param/Fiels map box.

Whatever i tried, the target url does not load the values from the param/Fiels map box.

Thanks in advance.
GreyHead 25 May, 2012
Hi karalismak ,

What settings are you using now? and what results do you get with Form Debug on?

Bob
GreyHead 29 May, 2012
Hi karalismak,

The Target URL is just the bit before the '?' - https://bxxxxxxxcom/api/http/send.php

The params/field box needs one 'param+input_name' pair on a line and the input names do not need curly brackets. So this entry needs to be:
name=name
date=date
phone=phone


Bob
karalismak 02 Jun, 2012
Hi GreyHead,

First of all when i use curl (Actions-->Redirect/Remote Submit) i can receive sms buth when i use cURL [GH] (Actions-->[GH] Custom actions) i don't.

Secondly, in the curl (Actions-->Redirect/Remote Submit) when i write

in the target url :
https://bulksms.xx/api/http/send.php or https://bulksms.xx/api/http/send.php?

and in the Params/Fields map:
username=xxxxx
password=xxxxx
from=xxxxx
to=xxxxx
message=name+date
name=name
date=date

the debug gives
[curl] => Error: Authentication error.
....
Debug Data
1.curl
1. CURL OK : the CURL function was found on this server.
2. $curl_values: name=karalis&phone=1111111111&date=28-06-2012
3. curl_target_url: https://bulksmsn.gr/api/http/send.php

and I don't receive sms.

But when I write
in the target url :
https://bulksms.xx/api/http/send.php?username=xxxxx&password=xxxxx&from=xxxxx&to=xxxxx&message=name+phone+date

and in the Params/Fields map:
name=name
phone=phone
date=date

the debug gives
[curl] => ID:0000B9B0
...
Debug Data
1.curl
1. CURL OK : the CURL function was found on this server.
2. $curl_values: name=karalis&phone=1111111111&date=26-06-2012 (//the values from the form//)
3. curl_target_url: https://bulksms.xx/api/http/send.php?username=xxxxx&password=xxxxx&from=xxxxx&to=xxxxx&message=name+date

In this case I receive sms with the following text: name phone date
(//not the values from the form,just this text//)

if i use URL [GH] (Actions-->[GH] with the above writing the debug gives:
[curl_gh] => Error: Authentication error.
....
Debug Data
1. cURL [GH]
1. cURL OK : the cURL function was found on this server.
2. cURL Target URL: https://bulksmsn.gr/api/http/send.php
3. Names + values (urldecoded)
1. username : xxxxx
2. password : xxxxx
3. from : xxxxx
4. to : xxxxx
5. message : name phone date
6. name : name
7. phone : phone
8. date : date
4. cURL Values: username=xxxxx&password=xxxxx&from=xxxxx&to=xxxxx&message=name+date&name=name&phone=phone&date=date
5. cURL:Resource id #92
6. cURL info: Array ( [url] => https://bulksms.xx/api/http/send.php [content_type] => text/html; charset=UTF-8 [http_code] => 200 [header_size] => 387 [request_size] => 255 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.065814 [namelookup_time] => 0.03747 [connect_time] => 0.037937 [pretransfer_time] => 0.057856 [size_upload] => 117 [size_download] => 28 [speed_download] => 425 [speed_upload] => 1777 [download_content_length] => 28 [upload_content_length] => 117 [starttransfer_time] => 0.065805 [redirect_time] => 0 [certinfo] => Array ( ) [redirect_url] => )
7. Response: Error: Authentication error.



I just want to receive an sms with the name,the phone and the date when somebody fills in the form.

Thanks in advance
karalismak 19 Jun, 2012
Hi GreyHead,

I am trying to write curl in the custom code.I have only add "show Html" on load and on submit the custom code :


<?php
$username = "xxxxx" ;
$password = "xxxxx" ;
$from = "xxxxx" ;
$to = "xxxxx" ;


//get form data
$name = $_POST['name'];
$phone = $_POST['phone'];
$date = $_POST['date'];

$vars = "username=".$username."&password=".$password."&from=".$from."&to=".$to."&message=".$name.$phone.$date;

if ($_POST['submitted']=="true")

{
    $curl = curl_init('https://bulkxxxx.xx/api/http/send.php');
	curl_setopt($curl, CURLOPT_POST, true);
	curl_setopt($curl, CURLOPT_POSTFIELDS, $vars);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	$result = curl_exec ($curl);
	curl_close($curl);
	
	die("Thank You");
}

?>


But still nothing happens.
Am I totally wrong or I have to make change?

Thanks in advance
GreyHead 01 Jul, 2012
Hi karalismak,

I don't see anything obviously wrong with the code do I guess that you need to debug step by step.

But why don't you use the ChronoForms cURL or my cURL [GH] action rather then code from scratch.

Bob
karalismak 01 Jul, 2012
Hi GreyHead,

Thanks a lot for your time. I believe we arevery close to send the desired sms.

Finally, I use your cURL action [GH].

From debuger:


Data Array:

Array
(
    [option] => com_chronoforms
    [chronoform] => makis2
    [event] => submit
    [Itemid] => 
    [onoma] => makis
    [phone] => 1111111111
    [date] => 01-08-2012
    [submit] => Submit
    [725211cd5e32baeaee776ef9943a660c] => 1
    [curl_gh] => Error: Authentication error.
)

Validation Errors:

Array
(
)

Debug Data

        cURL [GH]
        cURL OK : the cURL function was found on this server.
        cURL Target URL: https://bulksmsn.gr/api/http/send.php
        Names + values (urldecoded)
            username : xxxxx
            password : xxxxx
            from : xxxxx
            to : 2222222222
            message : makis11111111111-08-2012
        cURL Values: username=xxxxx&password=xxxxx&from=xxxxx&to=2222222222&message=makis11111111111-08-2012
        cURL:Resource id #106
        cURL info: Array ( [url] => https://bulksmsn.gr/api/http/send.php [content_type] => text/html; charset=UTF-8 [http_code] => 200 [header_size] => 387 [request_size] => 247 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.070511 [namelookup_time] => 0.038594 [connect_time] => 0.039155 [pretransfer_time] => 0.06317 [size_upload] => 109 [size_download] => 28 [speed_download] => 397 [speed_upload] => 1545 [download_content_length] => 28 [upload_content_length] => 109 [starttransfer_time] => 0.070428 [redirect_time] => 0 [certinfo] => Array ( ) [redirect_url] => )
        Response: Error: Authentication error.




The curl values are ok. But I cannot understand where is the problem now. The username, passwords etc are ok!

Thanks in advance
GreyHead 02 Jul, 2012
Hi karalismak,

Hard to say, the Authentication Error is from the BulkSMSN.gr site so my first thought is that the password or username is incorrect or the service isn't enabled.

Bob
karalismak 04 Jul, 2012
Hi Greyhead,

I would like to ask you what do you mean : the service isn't enabled?
HTTP API or something else?

Thanks in advance
GreyHead 04 Jul, 2012
Hi karalismak,

The bulksnsm.gr account with that username.

Bob
karalismak 10 Jul, 2012
Hi GreyHead,

I tried some other companies and finally it worked in one!!!
Unfortunately i have problem with the greek language in the sms.(gsm 7-bit is required).
Do you have any idea what can we do?

Moreover,I would like to ask if there would be any problem if the sms company requires GET Method in order to work their HTTP API?
Another company told me that their HTTP API requires GET METHOD.
cURL action what uses?

Thanks in advance
GreyHead 24 Jul, 2012
Hi karalismak,

Sorry I have no idea about the gsm 7-bit character set. The SMS service should be able to tell you how to handle that.

You can configure CURL to send using GET if you use my cURL [GH] action which allows you to set custom CURLOPT settings. See the PHP Manual for the list of options and explanations.

Bob
This topic is locked and no more replies can be posted.