mirror of
https://github.com/cwinfo/envayasms.git
synced 2024-11-15 04:40:26 +00:00
138 lines
4.1 KiB
HTML
138 lines
4.1 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta charset='utf-8'>
|
||
|
<meta http-equiv="cache-control" content="no-cache, must-revalidate" >
|
||
|
<title>EnvayaSMS: Upgrading to EnvayaSMS 3.0</title>
|
||
|
<link rel='stylesheet' type='text/css' href='/styles/site.css' />
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
<a href="http://github.com/youngj/EnvayaSMS"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
|
||
|
|
||
|
<div id="container">
|
||
|
|
||
|
<a style='float:left' href="/"><img src='/media/icon.png' height='72' width='72' style='margin-right:10px' /></a>
|
||
|
<h1 style='padding-top:13px'><a href="/">EnvayaSMS</a>
|
||
|
|
||
|
<span class="small">
|
||
|
SMS gateway for Android
|
||
|
</span>
|
||
|
|
||
|
</h1>
|
||
|
|
||
|
<div class='menu' style='clear:both;padding-top:5px'>
|
||
|
<a href='/'>Home</a>
|
||
|
·
|
||
|
<a href='/install/'>Install</a>
|
||
|
·
|
||
|
<a href='/test/'>Test</a>
|
||
|
·
|
||
|
<a href='/how/'>How it Works</a>
|
||
|
·
|
||
|
<a href='/serverapi/'>API Reference</a>
|
||
|
·
|
||
|
<a href='/faq/'>FAQ</a>
|
||
|
·
|
||
|
<a href='/history/'>History</a>
|
||
|
·
|
||
|
<a href='/community/'>Community</a>
|
||
|
</div>
|
||
|
|
||
|
<h2>Upgrading to EnvayaSMS 3.0</h2>
|
||
|
|
||
|
<p>
|
||
|
In EnvayaSMS version 3.0, the default format of HTTP responses changed to JSON (from XML in version 2).
|
||
|
</p>
|
||
|
<p>
|
||
|
In version 2, the server was expected to different responses depending on the action -- 'incoming' and 'outgoing'
|
||
|
actions returned an XML list of messages, while the response type for other actions was undefined.
|
||
|
</p>
|
||
|
<p>
|
||
|
In version 3, this behavior has been simplified -- now the server is expected to return a JSON response for <em>all</em>
|
||
|
actions. Each JSON response may contain a list of events. Optionally, users may configure AMQP to push events to the phone in real-time,
|
||
|
and each message in the AMQP queue represents a single event in the same JSON format.
|
||
|
</p>
|
||
|
<p>
|
||
|
To support this new API, the PHP server library has been changed. For backwards compatibility, the PHP server library
|
||
|
will generate either XML or JSON responses depending on the version of the EnvayaSMS app. However, phones that use EnvayaSMS
|
||
|
version 2 with the XML interface will only be able to receive outgoing messages (EnvayaSMS_Event_Send), not other events
|
||
|
added in version 3 (such as updating settings or canceling messages).
|
||
|
</p>
|
||
|
|
||
|
<p>
|
||
|
When you upgrade to the new version of the PHP server library, you will also need
|
||
|
to update your PHP code that uses the library.
|
||
|
</p>
|
||
|
|
||
|
<p>The following code examples assume you have the following variables:
|
||
|
<pre>
|
||
|
$request = EnvayaSMS::get_request();
|
||
|
$action = $request->get_action();
|
||
|
</pre>
|
||
|
|
||
|
<p>
|
||
|
Updating your PHP code is straightforward:
|
||
|
</p>
|
||
|
|
||
|
<h3>Setting HTTP Response Header</h3>
|
||
|
|
||
|
Old:
|
||
|
<pre>header("Content-Type: text/xml");</pre>
|
||
|
|
||
|
New:
|
||
|
<pre>
|
||
|
header("Content-Type: {$request->get_response_type()}");
|
||
|
</pre>
|
||
|
|
||
|
<h3>Sending Messages</h3>
|
||
|
|
||
|
Old:
|
||
|
<pre>$action->get_response_xml($messages);</pre>
|
||
|
|
||
|
New:
|
||
|
<pre>
|
||
|
$request->render_response(array(
|
||
|
new EnvayaSMS_Event_Send($messages)
|
||
|
));
|
||
|
</pre>
|
||
|
|
||
|
|
||
|
<h3>Returning an Error</h3>
|
||
|
|
||
|
Old:
|
||
|
<pre>EnvayaSMS::get_error_xml($error_message);</pre>
|
||
|
|
||
|
New:
|
||
|
<pre>$request->render_error_response($error_message);</pre>
|
||
|
|
||
|
<h3>Returning an Empty Successful Response</h3>
|
||
|
|
||
|
Old:
|
||
|
<pre>EnvayaSMS::get_success_xml();</pre>
|
||
|
|
||
|
New:
|
||
|
<pre>$request->render_response();</pre>
|
||
|
|
||
|
<div class="footer">
|
||
|
get the source code on GitHub : <a href="http://github.com/youngj/EnvayaSMS">youngj/EnvayaSMS</a>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
|
||
|
var _gaq = _gaq || [];
|
||
|
_gaq.push(['_setAccount', 'UA-25868450-2']);
|
||
|
_gaq.push(['_trackPageview']);
|
||
|
|
||
|
(function() {
|
||
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||
|
})();
|
||
|
|
||
|
</script>
|
||
|
|
||
|
</body>
|
||
|
</html>
|