/ Published in: PHP
                    
                                        
Example of how to send a subscribe_user request using Notifo's api. Notifo lets you setup push notifications to mobiles - for any site.
Put the PHP into a separate file named notifo-proxy.php
                Put the PHP into a separate file named notifo-proxy.php
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
// html + jquery
<script type="text/javascript" src="_assets/behaviour/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#notifo").submit(function(e) {
e.preventDefault();
$.getJSON("notifo-proxy.php?username=" + $("#username").attr("value"),
function (data) {
switch (parseInt(data.response_code)) {
case 2201:
//success
$('.result').html( "Success! " + data.response_message );
break;
case 2202:
//success - already registered
$('.result').html( "You're already subscribed! " + data.response_message );
break;
default:
//error - see the response codes of notifo's api
$('.result').html( "There was an error. " + data.response_message );
}
}
)
})
});
</script>
<div class="notfio">
<h1>Notifo Example</h1>
<form id="notifo" action="notifo-proxy.php" >
<input type="text" id="username" name="username" value="" />
<input type="submit" value="go" />
</form>
</div>
<div class="result">
<!-- server responses here -->
</div>
<?php
//-----------------------------------------------------------------------------------
//get username
$username = $_GET['username'];
//Create the connection handle
//Set cURL options
// Result from querying URL. Will parse as xml
// close cURL resource.
echo $output;
//-----------------------------------------------------------------------------------
?>
Comments
 Subscribe to comments
                    Subscribe to comments
                
                