1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP class for clickatell SMS gateway

Discussion in 'PHP' started by Mayhem Design, Sep 17, 2007.

  1. #1
    Hi Guys,

    I'm setting up an SMS interface using this class (http://www.phpclasses.org/browse/file/5564.html) and would like to be able to get a client message id into the class.

    In here
    $comm = sprintf ("%s/sendmsg?session_id=%s&to=%s&from=%s&text=%s&callback=%s%s",
    Code (markup):
    I need to be able to add &climsgid=xxx where xxx is the unique message id.

    To use the class I simply have to use
    $results = $mysms->send($_POST['to'],$_POST['from'],$_POST['message']);
    Code (markup):
    and I want to be able to add the message id in here.

    I hope this makes sense to someone. Any help will be greatly appreciated.
     
    Mayhem Design, Sep 17, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    nico_swd, Sep 17, 2007 IP
  3. Mayhem Design

    Mayhem Design Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I looked at them and they looked more expensive. 3.5p (AUD$0.08) for SMS in Australia where clickatell is only 6c at the lower volume rate, and cheaper for volume purchase.

    Thanks for the suggestion though
     
    Mayhem Design, Sep 17, 2007 IP
  4. omgitsfletch

    omgitsfletch Well-Known Member

    Messages:
    1,222
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    145
    #4
    Give me a few minutes to check it out. I may have something for you.
     
    omgitsfletch, Sep 17, 2007 IP
    guerilla likes this.
  5. omgitsfletch

    omgitsfletch Well-Known Member

    Messages:
    1,222
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    145
    #5
    I edited line 156 to add the extra parameter:
        function send($to=null, $from=null, $text=null, $climsgid=null) {
    PHP:
    Lines 188-196 now look like this:

          $comm = sprintf ("%s/sendmsg?session_id=%s&to=%s&from=%s&text=%s&climsgid=%s&callback=%s%s",
             $this->base,
             $this->session,
             rawurlencode($to),
             rawurlencode($from),
             rawurlencode($text),
             rawurlencode($climsgid),
             $this->callback,
             $concat
    PHP:
    and to call it, you should now do:

    $results = $mysms->send($_POST['to'],$_POST['from'],$_POST['message'], $climsgid);
    PHP:
    As far as I can tell, that should be the only edits necessary to support the extra variable you want. Let me know how it works.
     
    omgitsfletch, Sep 17, 2007 IP
  6. Mayhem Design

    Mayhem Design Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    omgitsfletch you are a legend. Thanks so much for your help. I knew it would be fairly straight forward but I'm still trying to get my head around OO programming and classes.

    Thanks heaps.
     
    Mayhem Design, Sep 17, 2007 IP
  7. omgitsfletch

    omgitsfletch Well-Known Member

    Messages:
    1,222
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    145
    #7
    Heh, well luckily in this case, it was a lot more work just modifying the class function than actually changing the class. If you go to php.net/sprintf, you'll find out a bit more on what that command is doing. Those %s represent variables, and the whole purpose of sprintf() is having variables out of the actual string to make it easier to understand. So it was just a matter of adding a variable, and putting it in the appropriate order underneath the sprintf().

    If you have any other problems, feel free to PM me. I'm here to help.
     
    omgitsfletch, Sep 18, 2007 IP