Jump to content

[SOLVED] Concatenation question (newbie)


mosey

Recommended Posts

Hi

I'm working on a mini-site for sending SMSs, and am using a 3rd party API found to do most of the backend work through the gateway. However, I'm a bit stuck (as a php newbie) as to how I can add on an extra variable to the message variable.

 

In more detail:

1. The user sees a standard web-form, which includes variables such as 'recipient number' 'message', where recipient number is an input box, and message is a textarea form.

2. The backend API takes the text from the message, and puts it through rawurlencode to ensure that it is correctly formatted. In this message, I am including a url e.g. http://www.google.com

3. I would like to append the recipient number variable to this url, so the user actually sees e.g.: http://www.google.com&recipient number

 

The way the backend API sends the message, is to concatenate all the values together: so something like this:

  	$comm = sprintf ("%s/sendmsg?session_id=%s&to=%s&from=%s&text=%s&callback=%s&unicode=%s%s",
            $this->base,
            $this->session,
            rawurlencode($to),
            rawurlencode($from),
            $this->encode_message($text),
            $this->callback,
            $this->unicode,
            $concat
        );

 

I have tried simply just using

   $this->encode_message($text) ."&". $to,

or

   $this->encode_message($text)  ."&". ($to),

or

   $this->encode_message($text)." &". rawurlencode($to),

 

to no avail, so would really appreciate it if a more experienced user wouldn't mind suggesting a solution or tip to resolve this issue.

 

Thanks in advance! :)

 

p/s:

$this->encode_message($text)

is outputted as

rawurlencode($text)

- it is setup like this in case the message is sent in unicode and has to be processed further.

Link to comment
https://forums.phpfreaks.com/topic/65269-solved-concatenation-question-newbie/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.