Nairobi Posted April 26, 2012 Share Posted April 26, 2012 hey guys iam developing an sms app in Kenya and ive hit a dead end. The app is a keyword response app where users can get match fixtures updates, league results,live updates etc please help . when i test the app on the sanbox i keep getting errors. here is the project outline The API The API is currently very straightforward. There is a single function you need to implement that our platform will call. ETxtResponse ProcessEtxtRequest(ETxtRequest mo); ETxtResponse and ETxtRequest both have the same properties public Guid Id { get; set; } public string Message { get; set; } public string SessionState { get; set; } public string CustomerState { get; set; } Request: Guid Id - you can use this to identify a unique session with a unique customer. string Message - the text message the customer sent. string SessionState - the transient session data retrieved by our platform and passed to you. string CustomerState - the permanent customer data retrieved by our platform and passed to you. Response: Guid Id - Should be the same as the request you are responding to. string Message - the text message you want us to send back to the customer. string SessionState - the transient session data you want us to save. string CustomerState - the permanent customer data you want us to save. How you implement this method depends on the type of contract you choose. There are currently 3 options - XML, JSON and FORM POST. XML SOAP XMLWebService : IServerApi This is an XML-based implementation which will pass the request in SOAP-XML and expect a response as SOAP-XML. <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="false" /> <behaviors> <serviceBehaviors> <behavior name="FmnSoftBehavior" /> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="FmnSoftBehavior" name="FmnSoft.TestApiServices.Calculator"> <endpoint address="" binding="basicHttpBinding" contract="IServerApi" /> </service> </services> </system.serviceModel> [serviceContract] public interface IServerApi { [OperationContract] ETxtResponse ProcessEtxtRequest(ETxtRequest mo); } JSON JsonWebService : IJsonServerApi This is a Javscript based implementation which will pass the request as a JSON encoded object and expect a response as a JSON encoded object. <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="false" /> <behaviors> <serviceBehaviors> <behavior name="FmnSoftBehavior" /> </serviceBehaviors> <endpointBehaviors> <behavior name="FmnSoftEndPoint"> <webHttp/> </behavior> </endpointBehaviors> </behaviors> <services> <service name="FmnSoft.TestApiServices.JsonCalc" behaviorConfiguration=" FmnSoftBehavior "> <endpoint address="" behaviorConfiguration="FmnSoftEndPoint" binding="webHttpBinding" contract="IJsonServerApi" /> </service> </services> </system.serviceModel> [serviceContract] public interface IJsonServerApi { [OperationContract] [WebInvoke( Method = "POST", UriTemplate = "/ProcessEtxtRequest", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] ETxtResponse ProcessEtxtRequest(ETxtRequest mo); } FORM POST FormPost implementation : text/xml response. This is a HTTP-POST implementation which will pass the request as formdata in a HTTP POST. It will expect the response content-type to be "text/xml" and the response itself to be serialised to XML. POST http://yourserver/yourform.htm HTTP/1.1 Content-Type: application/x-www-form-urlencoded Host: yourserver Content-Length: 80 Expect: 100-continue Connection: Keep-Alive Id=d1a7ecd6-5fe5-4d5a-9d85-0c71aa1cbd04&Message=#c2&SessionState=&CustomerState= The response you send back from this must be in XML format. HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: 140 Connection: Close <mt> <id>44b497d0-b43e-40c1-b0c0-d8c190b1e38f</id> <msg>Reply with the second number to add</msg> <sessionstate>3</sessionstate> <customerstate>Pippa</customerstate> </mt> ... And here is my code <?php $id = $_POST["Id"]; $sessionstate = $_POST["SessionState"]; $customerstate = $_POST["CustomerState"]; $message = $_POST["Message"]; if ($message == “#ligi”){ $sessionState“”; $msg=“ 1] match fixture <br /> 2] match results<br /> 3]leasgue standings<br /> 4]kpl news<br /> 5]Ongoing Live results”; } if ($message == “#1”){ $sessionState“”; $msg=“match fixtures <br /> 13:00hrs<br /> KCB vs Karuturi<br /> 15:00hrs<br /> Oserian vs Muhoroni<br />Mathare vs Western<br /> AFC vs Tusker ”; } if ($message == “#2”){ $sessionState“”; $msg=“ match results<br /> 15-04-2012<br />Tusker 2 – 2 Mathare<br />Chemelil 1 – 0KCB<br /> Gor Mahia 1 – 0 sofapaka<br /> City Stars 0 – 0 Ulinzi Stars”; } if ($message = “#3”){ $sessionState“”; $msg=“ leasgue standings <br /> As of 15-04-2012<br />AFC:26pts<br /> Sofapaka:20pts<br />Chemelil:20pts<br /> Tusker:19pts<br /> Thika United:14pts<br /> Western Stima:14pts<br />Muhoroni:14pts”); } if ($message ==“#4”){ $sessionState“”; $msg=“kpl news<br /> 15-04-2012<br />Gor mahia gets banned for 3 matches by premier league,afc sign in congolese striker atwete”; } if ($message == “#5”){ $sessionState“”; $msg=“Ongoing Live results <br />mathare o gormahia o,ulinzi 4 tusker 3”; } } header('Content-type: text/xml'); header('Character-encod ing: utf-8'); $out = '<xml><mt id="123456"><msg>Hello World</msg><sessionstate>session1</sessionstate><customerstate>customer1</customerstates></mt></xml>'; echo $out; ?> ... Quote Link to comment https://forums.phpfreaks.com/topic/261650-sms-application-please-help/ Share on other sites More sharing options...
RussellReal Posted April 27, 2012 Share Posted April 27, 2012 what is the error you're getting? [Edited This Block Out -- I overlooked the last block of code] The JSON Response doesn't look much like JSON, although that really doesn't matter too much.. Please respond with the PHP Error Message, and I'd be happy to assist you! - Russell Crevatas Quote Link to comment https://forums.phpfreaks.com/topic/261650-sms-application-please-help/#findComment-1340956 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.