本文整理汇总了PHP中Connect::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP Connect::connect方法的具体用法?PHP Connect::connect怎么用?PHP Connect::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connect
的用法示例。
在下文中一共展示了Connect::connect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendGCMMessage
public static function sendGCMMessage($title, $msg, $eventoId, $disciplina)
{
include "../webservice/connection/Connect.php";
$db = new Connect();
$connection = $db->connect();
//$acao = $_POST['acao'];
// if ($acao == "enviar") {
$jsonArray = array();
$sql = $connection->prepare("SELECT app_dispositivo.registration_id FROM henriqueweb.app_dispositivo");
$sql->execute();
if ($sql->rowCount() > 0) {
while ($tmp = $sql->fetch()) {
$jsonArray[] = $tmp["registration_id"];
}
}
//$mensagem = $_POST["mensagem"];
//$eventoId = $_POST["eventoId"];
$url = "https://gcm-http.googleapis.com/gcm/send";
$apiKey = "AIzaSyD4-EStQ8w7G8FP2plyIkIOJ10LljchUpw";
$ch = curl_init($url);
$jsonData = array("registration_ids" => $jsonArray, "data" => array("type" => "evento", "title" => $title, "disciplina" => $disciplina, "eventoId" => $eventoId, "mensagem" => $msg));
$jsonDataEncoded = json_encode($jsonData);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: key=" . $apiKey));
$result = curl_exec($ch);
//}
}
示例2: json_encode
<?php
header('Content-Type: application/json; Charset=UTF-8');
include "../connection/Connect.php";
$db = new Connect();
$connection = $db->connect();
$sql = "UPDATE app_rating_disciplina SET app_rating = ? WHERE (app_aluno_key = ?) AND (app_disciplina_key = ?)";
$query = $connection->prepare($sql);
$disciplinaRating = $_POST['disciplinaRating'];
$alunoKey = $_POST['alunoKey'];
$disciplinaKey = $_POST['disciplinaKey'];
$query->execute(array($disciplinaRating, $alunoKey, $disciplinaKey));
$returnJson = array("updated" => $query->rowCount());
echo json_encode($returnJson);