PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Old April 4th, 2007, 03:12 PM
crampey crampey is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: UK
Posts: 2 crampey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sending MMS Script

Hi

I am working on producing a projet that allows a mobile user to send a 'keyword' to a short code number, which then forwards that text to a URL.
The forwarding also includes:

Forwarded to http://doamin with parameters:
source=447977925144
dest=60300
dtime=200704030049
message=Mobile yes
network=33
message_id=39961218906
message_after_match=
matched_keyword=Mobile
matched_subkeyword=yes

The forwarding is working fine, the problem is getting the number (source) into the script held on my server.
The aim is once this has all the user parameters included it will call content held on a local server running NowSms Gateway via this script.

php Code:
Original - php Code
  1.  
  2. <?
  3.  
  4. function PostToHost($host, $port, $username, $password, $data_to_send)
  5. {
  6.     $dc = 0;
  7.    $bo ="-----------------------------305242850528394";
  8.  
  9.     $fp = fsockopen($host, $port, $errno, $errstr);
  10.     if (!$fp) {
  11.         echo "errno: $errno n";
  12.         echo "errstr: $errstrn";
  13.         return $result;
  14.     }
  15.  
  16.     fputs($fp, "POST / HTTP/1.1rn");
  17.     if ($username != "") {
  18.        $auth = $username . ":" . $password;
  19.        echo "auth: $authn";
  20.        $auth = base64_encode($auth);
  21.        echo "auth: $authn";
  22.        fwrite($fp, "Authorization: Basic " . $auth . "rn");
  23.     }
  24.     fputs($fp, "User-Agent: NowSMS PHP Scriptrn");
  25.     fputs($fp, "Accept: */*rn");
  26.     fputs($fp, "Content-type: multipart/form-data; boundary=$born");
  27.     
  28.     foreach($data_to_send as $key=>$val) {
  29.         $ds =sprintf("%srnContent-Disposition: form-data; name="%s"rn%srn",$bo,$key,$val);
  30.         $dc += strlen($ds);
  31.        
  32.     }
  33.     $dc += strlen($bo)+3;
  34.     fputs($fp, "Content-length: $dcrn");
  35.     fputs($fp, "rn");
  36.     fputs($fp, "This is a MIME messagernrn");
  37.  
  38.     foreach($data_to_send as $key=>$val) {
  39.         $ds =sprintf("%srnContent-Disposition: form-data; name="%s"rn%srn",$bo,$key,$val);
  40.         fputs($fp, $ds );
  41.     }
  42.     $ds = $bo."--rn" ;
  43.     fputs($fp, $ds);
  44.  
  45.     $res = "";
  46.  
  47.     while(!feof($fp)) {
  48.         $res .= fread($fp,1);
  49.     }
  50.     fclose($fp);
  51.    
  52.  
  53.     return $res;
  54. }
  55.  
  56.  
  57.  
  58. $file1="C:\TEMP\logo.gif";
  59. $contenttype1 = "image/gif";
  60.  
  61. $fa = @file($file1);
  62. $xf ="Content-Type: ".$contenttype1."rnrn".implode("",$fa);
  63. $data["MMSFile"; filename="$file1"]   = $xf;
  64.  
  65. $file2="C:\TEMP\test.smil";
  66. $contenttype2 = "application/smil";
  67.  
  68. $fa = @file($file2);
  69. $xf="Content-Type: ".$contenttype2."rnrn".implode("",$fa);
  70. $data["MMSFile"; filename="$file2"]   = $xf;
  71.  
  72. /* Repeat this sequence for additional parts
  73. $file3="C:\TEMP\?????.???";
  74. $contenttype3 = "?????";
  75. $fa = @file($file3);
  76. $xf="Content-Type: ".$contenttype3."rnrn".implode("",$fa);
  77. $data["MMSFile"; filename="$file3"]   = $xf;
  78. */
  79.  
  80.  
  81. /* A quirk of this script is that you must start all non-file parameters with rn */
  82. $data["MMSFrom"]     = "rn" . "sender@domain.com";
  83. $data["PhoneNumber"] = "rn" . "+44999999999";
  84. $data["MMSSubject"]  = "rn" . "Subject of message" ;
  85.  
  86. /* The MMSText field is optional */
  87. $data["MMSText" ]    = "rn" . "Hello!" ;
  88.  
  89.  
  90.  
  91. $x   = PostToHost("127.0.0.1", 81, "test", "test", $data);
  92. echo $x;
  93.  


This NowSMS Gateway held locally, once called by the script sends content back to the 'source' via MMS to their mobile phone.

The problem is how to get the forwarded parameters into the script to enable it to be run.

Any ideas?

Thanks Robin

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Sending MMS Script


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap