本文整理汇总了PHP中School::fromFacebook方法的典型用法代码示例。如果您正苦于以下问题:PHP School::fromFacebook方法的具体用法?PHP School::fromFacebook怎么用?PHP School::fromFacebook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类School
的用法示例。
在下文中一共展示了School::fromFacebook方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: die
header('Content-type: application/json');
if (!$authenticated) {
die(json_encode(array('success' => 0, 'message' => 'You are not logged in.')));
}
if ($invalidparameters) {
die(json_encode(array('success' => 0, 'message' => 'Invalid parameters.')));
}
$collegeid = $_REQUEST['college'];
$lat = $_REQUEST['latitude'];
$lng = $_REQUEST['longitude'];
$imageurl = $_REQUEST['image'];
if (empty($collegeid)) {
die(json_encode(array('success' => 0, 'message' => 'Invalid data.')));
}
$college = new School($collegeid);
if (!$college->fromFacebook($facebook)) {
die(json_encode(array('success' => 0, 'message' => 'Cannot find school.')));
}
$assocs = $db->getAssociations($myself, AssociationTypes::College);
$canedit = false;
if ($assocs) {
foreach ($assocs as $assoc) {
if ($assoc == $collegeid) {
$canedit = true;
}
}
}
if (!$canedit) {
die(json_encode(array('success' => 0, 'message' => 'You do not have permissions to edit this school.')));
}
if (!empty($imageurl)) {
示例2:
// try getting cached data from db
// if we fail, this concentration doesn't exist yet
$concentration->fromFacebook($facebook);
$concentration->updateDatabase($db);
}
$db->addAssociation($myself, $concentration->id, AssociationTypes::Concentration);
}
}
// add college
if (!$college->fromDatabase($db)) {
// try getting cached data from db
// if we fail, this college doesn't exist yet
if ($college->id == 0) {
$college->name = 'No School';
} else {
$college->fromFacebook($facebook);
$college->updateDatabase($db);
}
}
$db->addAssociation($myself, $college->id, AssociationTypes::College);
// add highschool
if (!$myhs->fromDatabase($db)) {
$myhs->fromFacebook($facebook);
$myhs->updateDatabase($db);
}
$db->addAssociation($myself, $myhs->id, AssociationTypes::HighSchool);
// add user
$myself->fromFacebook($facebook);
// update information
if (is_numeric($_REQUEST['rank'])) {
$myself->rank = $_REQUEST['rank'];
示例3: School
// get my high school data
$hs_associds = $db->getAssociations($myself->id, AssociationTypes::HighSchool);
$myhs = $hs_associds[0];
if (!$myhs) {
if (!isset($myfb['education'])) {
$myhs = new School(0);
} else {
foreach ($myfb['education'] as $education) {
if ($education['type'] == "High School") {
$hsid = $education['school']['id'];
break;
}
}
$myhs = new School($hsid);
if (!$myhs->fromDatabase($db)) {
$myhs->fromFacebook($facebook);
}
}
}
// get current page data
$schoolid = $_REQUEST['school'];
$curyear = $_REQUEST['year'];
$curhs = new School($schoolid);
$invalidparameters = false;
if (!isset($_REQUEST['school']) || !isset($_REQUEST['year']) || !$curhs->fromFacebook($facebook) || !is_numeric($curyear) || $curyear < 1900 || $curyear > 2900) {
$invalidparameters = true;
$curyear = $myself->year;
$curhs = $myhs;
}
// writable if we are in the current hs
$writeable = $curhs->id == $myhs->id;
示例4: json_encode
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
require_once 'master.php';
header('Content-type: application/json');
if ($invalidparameters) {
die(json_encode(array('success' => 0, 'message' => 'Invalid parameters.')));
}
if (!isset($_REQUEST['college']) || !is_numeric($_REQUEST['college'])) {
die(json_encode(array('success' => 0, 'message' => 'Invalid school.')));
}
$schoolid = $_REQUEST['college'];
$school = new School($schoolid);
if (!$school->fromDatabase($db)) {
if (!$school->fromFacebook($facebook)) {
// we shouldn't have to do this!
die(json_encode(array('success' => 0, 'message' => 'Cannot find school.')));
}
}
$data = array('success' => 1, 'totalStudents' => $db->getTotalCount($curhs, $curyear), 'information' => array('id' => $school->id, 'name' => $school->name, 'image' => $school->imageurl, 'location' => array('latitude' => (int) $school->latitude, 'longitude' => (int) $school->longitude), 'studentsAttending' => $db->getAttendingCount($school, $curhs, $curyear), 'friendsAttending' => $db->getAttendingCount($school, $curhs, $curyear, $facebook, $myself)));
echo json_encode($data);