This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DB_Functions { | |
private $db; | |
//put your code here | |
// constructor | |
function __construct() { | |
include_once './db_connect.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Registering a user device | |
* Store reg id in users table | |
*/ | |
$body = file_get_contents('php://input'); | |
$postvars = json_decode($body, true); | |
if (isset($postvars["name"]) && isset($postvars["email"]) && isset($postvars["regId"])) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS `gcm_users` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`gcm_regid` text, | |
`name` varchar(50) NOT NULL, | |
`email` varchar(255) NOT NULL, | |
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: REST API Custom | |
Plugin URI: http://hungdh.me | |
Description: Add metadata, end point to the REST API | |
Author: Huy Hung | |
Version: 1.0 | |
Author URI: http://hungdh.me | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void sendRequest(int zodiacID, int gender) { | |
JSONObject params = new JSONObject(); | |
try { | |
params.put(PARAM_ZODIAC_ID, String.valueOf(zodiacID)); | |
params.put(PARAM_GENDER_ID, String.valueOf(gender)); | |
params.put(PARAM_DATE, mDate); | |
} catch (JSONException e) { | |
e.printStackTrace(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function connect() { | |
require_once 'config.php'; | |
$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); | |
// selecting database | |
mysql_select_db(DB_DATABASE); | |
// return database handler | |
return $con; | |
} | |
// Closing database connection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function send_notification($registration_ids, $message) { | |
include_once './config.php'; | |
// Set POST variables | |
$url = 'https://android.googleapis.com/gcm/send'; | |
$fields = array( | |
'registration_ids' => $registration_ids, | |
'data' => $message, | |
); | |
$headers = array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (isset($_GET["regId"]) && isset($_GET["message"])) { | |
$regId = $_GET["regId"]; | |
$message = $_GET["message"]; | |
include_once './GCM.php'; | |
$gcm = new GCM(); | |
$registatoin_ids = array($regId); | |
$message = array("message" => $message); | |
$result = $gcm->send_notification($registatoin_ids, $message); | |
echo $result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.hungdh.gcmdemo; | |
public class MainActivity extends AppCompatActivity { | |
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000; | |
private static final String TAG = "MainActivity"; | |
private BroadcastReceiver mRegistrationBroadcastReceiver; | |
private ProgressBar mRegistrationProgressBar; | |
private TextView mInformationTextView; |
OlderNewer