Notifo使用PHPCURL和Jquery订阅请求
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Notifo使用PHPCURL和Jquery订阅请求相关的知识,希望对你有一定的参考价值。
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
// 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; //----------------------------------------------------------------------------------- ?>
以上是关于Notifo使用PHPCURL和Jquery订阅请求的主要内容,如果未能解决你的问题,请参考以下文章