本文整理汇总了PHP中getJson函数的典型用法代码示例。如果您正苦于以下问题:PHP getJson函数的具体用法?PHP getJson怎么用?PHP getJson使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getJson函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public function add()
{
$js = intval($_GET['js']);
$userid = aac('user')->isLogin(1);
//判断发布者状态
/*
if(aac('user')->isPublisher()==false) {
getJson('不好意思,你还没有权限发布内容!',$js);
}
*/
if ($_POST['token'] != $_SESSION['token']) {
getJson('非法操作!', $js);
}
$content = tsClean($_POST['content']);
if ($content == '') {
getJson('内容不能为空', $js);
}
$isaudit = 0;
//过滤内容开始
aac('system')->antiWord($content);
//过滤内容结束
$weiboid = $this->create('weibo', array('userid' => $userid, 'locationid' => aac('user')->getLocationId($userid), 'content' => $content, 'isaudit' => $isaudit, 'addtime' => date('Y-m-d H:i:s'), 'uptime' => date('Y-m-d H:i:s')));
//feed开始
$feed_template = '<span class="pl">说:</span><div class="quote"><span class="inq">{content}</span> <span><a class="j a_saying_reply" href="{link}" rev="unfold">回应</a></span></div>';
$feed_data = array('link' => tsurl('weibo', 'show', array('id' => $weiboid)), 'content' => cututf8(t($content), '0', '50'));
aac('feed')->add($userid, $feed_template, $feed_data);
//feed结束
getJson('发布成功!', $js, 2, tsurl('weibo', 'show', array('id' => $weiboid)));
}
示例2: getAnimals
function getAnimals()
{
$animals = [];
foreach (glob(__DIR__ . '/lib/animals/*.json') as $path) {
$info = pathinfo($path);
$animals[$info['filename']] = getJson($path);
}
return $animals;
}
示例3: bindCacheSetting
function bindCacheSetting()
{
global $_FANWE;
$settings = array();
$js_settings = array();
$res = FDB::query("SELECT name,val,is_js FROM " . FDB::table('sys_conf') . " WHERE status = 1");
while ($data = FDB::fetch($res)) {
$name = strtolower($data['name']);
$settings[$name] = $data['val'];
if ($data['is_js'] == 1) {
$js_settings[$name] = $data['val'];
}
}
$settings['site_title'] .= ' - ' . 'F' . 'A' . 'N' . 'W' . 'E';
$settings['footer_html'] .= '<' . 'p' . '>' . '<' . 'a' . ' ' . 'h' . 'r' . 'e' . 'f' . '=' . '"' . 'h' . 't' . 't' . 'p' . ':' . '/' . '/' . 'w' . 'w' . 'w' . '.' . 'f' . 'a' . 'n' . 'w' . 'e' . '.' . 'c' . 'o' . 'm' . '"' . ' ' . 't' . 'a' . 'r' . 'g' . 'e' . 't' . '=' . '"' . '_' . 'b' . 'l' . 'a' . 'n' . 'k' . '"' . '>' . 'f' . 'a' . 'n' . 'w' . 'e' . '.' . 'i' . 'n' . 'c' . '<' . '/' . 'a' . '>' . '<' . '/' . 'p' . '>';
writeFile(PUBLIC_ROOT . './js/setting.js', 'var SETTING = ' . getJson($js_settings) . ';');
$config_file = @file_get_contents(PUBLIC_ROOT . 'config.global.php');
$config_file = trim($config_file);
$config_file = preg_replace("/[\$]config\\['time_zone'\\].*?=.*?'.*?'.*?;/is", "\$config['time_zone'] = '" . $settings['time_zone'] . "';", $config_file);
$config_file = preg_replace("/[\$]config\\['default_lang'\\].*?=.*?'.*?'.*?;/is", "\$config['default_lang'] = '" . $settings['default_lang'] . "';", $config_file);
@file_put_contents(PUBLIC_ROOT . 'config.global.php', $config_file);
unset($config_file);
$lang_arr = array();
$lang_files = array(FANWE_ROOT . './core/language/' . $settings['default_lang'] . '/template.lang.php', FANWE_ROOT . './tpl/' . $settings['site_tmpl'] . '/template.lang.php');
foreach ($lang_files as $lang_file) {
if (@(include $lang_file)) {
foreach ($lang as $lkey => $lval) {
$lang_pre = strtolower(substr($lkey, 0, 3));
if ($lang_pre == 'js_') {
$lang_key = substr($lkey, 3);
if ($lang_key != '') {
$lang_arr[$lang_key] = $lval;
}
}
}
}
}
writeFile(PUBLIC_ROOT . './js/lang.js', 'var LANG = ' . getJson($lang_arr) . ';');
clearDir(FANWE_ROOT . './public/data/tpl/css/');
clearDir(FANWE_ROOT . './public/data/tpl/js/');
$css_dir = FANWE_ROOT . './tpl/' . $settings['site_tmpl'] . '/css/';
$css_cache_dir = FANWE_ROOT . './public/data/tpl/css/';
$css_site_path = $_FANWE['site_root'] . 'tpl/' . $settings['site_tmpl'] . '/';
$directory = dir($css_dir);
while ($entry = $directory->read()) {
if ($entry != '.' && $entry != '..' && stripos($entry, '.css') !== false) {
$css_path = $css_dir . $entry;
$css_content = @file_get_contents($css_path);
$css_content = preg_replace("/\\.\\.\\//", $css_site_path, $css_content);
$css_cache_path = $css_cache_dir . '/' . $entry;
writeFile($css_cache_path, $css_content);
}
}
$directory->close();
FanweService::instance()->cache->saveCache('setting', $settings);
}
示例4: pullDataForSign
function pullDataForSign(&$sign)
{
$sid = $sign->sid;
$result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $sid . ".json?key=TEST&date=2015-12-21");
// weekday
$sign->stopName = $result['data']['references']['stops'][0]['name'];
$stopSchedules = array();
$groupedSchedules = array();
// get weekday schedules
createSchedules($result, $stopSchedules, $groupedSchedules, 'wkday');
// get saturday schedules
$result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $sid . ".json?key=TEST&date=2015-12-19");
// saturday
createSchedules($result, $stopSchedules, $groupedSchedules, 'sat');
// get sunday schedules
$result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $sid . ".json?key=TEST&date=2015-12-20");
// sunday
createSchedules($result, $stopSchedules, $groupedSchedules, 'sun');
// Above we marked certain headsigns as "AMBIGUOUS"
// b/c the same text might be used for multiple directions of travel.
// Merge 'AMBIGUOUS' schedules with another schedule of the same route (MARTA 12).
$deleteCandidates = array();
foreach ($groupedSchedules as $ss) {
if ($ss['direction2'] == 'AMBIGUOUS') {
foreach ($groupedSchedules as &$ss1) {
if ($ss1['name'] == $ss['name'] && $ss1['direction2'] != 'AMBIGUOUS') {
array_push($deleteCandidates, $ss);
$ss1['wkday'] = array_merge($ss1['wkday'], $ss['wkday']);
$ss1['sat'] = array_merge($ss1['sat'], $ss['sat']);
$ss1['sun'] = array_merge($ss1['sun'], $ss['sun']);
sort($ss1['wkday']);
sort($ss1['sat']);
sort($ss1['sun']);
break;
}
}
}
}
foreach ($deleteCandidates as $dc) {
unset($groupedSchedules[$dc['finalDestination']]);
}
// // This is to center single schedules on the sheet.
// if (count($stopSchedules) == 1) {
// array_unshift($stopSchedules, null);
// array_push($stopSchedules, null);
// }
// if (count($groupedSchedules) == 1) {
// array_unshift($groupedSchedules, null);
// array_push($groupedSchedules, null);
// }
$sign->stopSchedules = $stopSchedules;
$sign->groupedSchedules = $groupedSchedules;
}
示例5: main
function main()
{
if (isset($_GET['lang']) && $_GET['lang'] == 'en') {
$lang = 'en';
} else {
$lang = 'no';
}
$json = getJson($lang);
$form = parsePost($json);
if (strlen($form['result']) > 0) {
// If all fields in $_POST were valid
saveForm($form['name'], $form['email'], $form['message']);
}
require 'cvLayout.php';
}
示例6: seperateInfo
function seperateInfo()
{
$obj = getJson();
$amount = count($obj);
$objectenArray = [];
$infoArray = [];
for ($i = 0; $i < $amount; ++$i) {
$id = $obj[$i]['id'];
$foto = $obj[$i]['images']['standard_resolution']['url'];
array_push($infoArray, $id);
array_push($infoArray, $foto);
array_push($objectenArray, $infoArray);
$infoArray = [];
}
return $objectenArray;
}
示例7: shareCount
function shareCount($url, $site)
{
function getJson($url)
{
$shareCountData = file_get_contents($url);
$result = json_decode($shareCountData);
return $result;
}
if ($site == 'facebook') {
$result = getJson('http://graph.facebook.com/?id=' . $url);
return intval($result->shares);
}
if ($site == 'twitter') {
$result = getJson('http://cdn.api.twitter.com/1/urls/count.json?url=' . $url);
return intval($result->count);
}
if ($site == 'linkedin') {
$result = getJson('http://www.linkedin.com/countserv/count/share?url=' . $url . '&format=json');
return intval($result->count);
}
if ($site == 'pinterest') {
$result = file_get_contents('http://api.pinterest.com/v1/urls/count.json?url=' . $url);
$result = json_decode(preg_replace('/^receiveCount\\((.*)\\)$/', "\\1", $result));
return intval($result->count);
}
if ($site == 'googleplus') {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://clients6.google.com/rpc");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' . $url . '","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
$result = curl_exec($curl);
curl_close($curl);
$json = json_decode($result, true);
return intval($json[0]['result']['metadata']['globalCounts']['count']);
}
if ($site == 'stumbleupon') {
$result = getJson('http://www.stumbleupon.com/services/1.01/badge.getinfo?url=' . $url);
return $result->result->views;
}
return "invalid request";
}
示例8: printPageForStop
function printPageForStop($stop)
{
$agency = $stop[0];
$sid = $stop[1];
$stopId1 = $stop[0];
$result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $stopId1 . ".json?key=TEST&date=2015-09-08");
// weekday
$stopName = $result['data']['references']['stops'][0]['name'];
if (isset($_REQUEST['stopNameOverride']) && $_REQUEST['stopNameOverride'] != "") {
$stopName = $_REQUEST['stopNameOverride'];
}
$routes = $result['data']['references']['routes'];
$stopSchedules = array();
$groupedSchedules = array();
// FIRST bus stop
// get weekday schedules
createSchedules($result, $stopSchedules, 'wkday');
// get saturday schedules
$result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $stopId1 . ".json?key=TEST&date=2015-04-04");
// saturday
createSchedules($result, $stopSchedules, 'sat');
// get sunday schedules
$result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $stopId1 . ".json?key=TEST&date=2015-04-05");
// sunday
createSchedules($result, $stopSchedules, 'sun');
// SECOND BUS STOP if available
$stopId2 = $stop[1];
if ($stopId2 != "") {
// get weekday schedules
$result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $stopId2 . ".json?key=TEST&date=2015-09-08");
// weekday
createSchedules($result, $stopSchedules, 'wkday');
// get saturday schedules
$result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $stopId2 . ".json?key=TEST&date=2015-04-04");
// saturday
createSchedules($result, $stopSchedules, 'sat');
// get sunday schedules
$result = getJson("http://atlanta.onebusaway.org/api/api/where/schedule-for-stop/" . $stopId2 . ".json?key=TEST&date=2015-04-05");
// sunday
createSchedules($result, $stopSchedules, 'sun');
}
$groupedSchedules = createMergedSchedules($stopSchedules);
// Above we marked certain headsigns as "AMBIGUOUS"
// b/c the same text might be used for multiple directions of travel.
// Merge 'AMBIGUOUS' schedules with another schedule of the same route (MARTA 12).
$deleteCandidates = array();
foreach ($groupedSchedules as $ss) {
if ($ss['direction2'] == 'AMBIGUOUS') {
foreach ($groupedSchedules as &$ss1) {
if ($ss1['name'] == $ss['name'] && $ss1['direction2'] != 'AMBIGUOUS') {
array_push($deleteCandidates, $ss);
$ss1['wkday'] = array_merge($ss1['wkday'], $ss['wkday']);
$ss1['sat'] = array_merge($ss1['sat'], $ss['sat']);
$ss1['sun'] = array_merge($ss1['sun'], $ss['sun']);
sort($ss1['wkday']);
sort($ss1['sat']);
sort($ss1['sun']);
break;
}
}
}
}
foreach ($deleteCandidates as $dc) {
unset($groupedSchedules[$dc['finalDestination']]);
}
// print
echo "<div class='page'>";
echo "<div id='fold'></div>";
printPageHeader($stopName);
//echo "<div id='pageBody'>";
echo "<div id='mapFold'>";
echo "<img src='img/fakemap.png' style='width:100%; height:75%;' />";
echo "</div>";
echo "<div id='scheduleFold'>";
echo "<div class='buses'>";
//echo "<ul>";
foreach ($stopSchedules as $ss) {
//echo "<li>" . $ss['direction2'] . "</li>";
//printRouteInfo($ss);
}
foreach ($groupedSchedules as $ss) {
//echo "<li>" . $ss['direction2'] . "</li>";
printRouteInfo($ss);
}
//echo "</ul>";
echo "</div>";
echo <<<EOT
\t<div class='disclaimer'>
\t\t*Trip times are approximate, may change without notice, and may vary with road conditions, events, and holidays. Data provided by MARTA and OneBusAway.
\t\t<br /><span class='alt-lang'>*Los horarios son indicativos, pueden cambiar sin aviso previo y cambiar en función de las condiciones de circulación, eventos, y días festivos.</span>
\t</div>
EOT;
echo "</div>";
//echo "</div><!-- pageBody -->";
printPageFooter($sid);
echo "</div>";
echo "<div style='clear:both; page-break-after: always;'><" . "/div>";
}
示例9: getJson
require_once "include/academic/lecturerexalresultdelete.php";
break;
case "UserManagement":
require_once "include/admission/usermanagement.php";
break;
default:
require_once "include/profile/default.php";
break;
}
// end content
// news
$template->loadTemplateFile("footer.tpl");
$template->setCurrentBlock("news");
$template->setVariable("NEWS", "Intranet News");
//$template->parseCurrentBlock();
$json = getJson($url_json);
//die($json);
$arr = json_decode($json);
//var_dump($arr);
$template->setCurrentBlock("article");
foreach ($arr as $obj) {
//die$obj->guid;
$template->setVariable("NEWSLINK", $obj->guid);
$template->setVariable("NEWSTITLE", $obj->post_title);
$template->setVariable("NEWSCONTENT", limit_text($obj->post_content, 15));
$template->setVariable("NEWSDATE", $obj->post_date);
$template->setVariable("NEWSAUTHOR", $obj->user_nicename);
$template->parseCurrentBlock();
}
$template->parse("newsinner");
$template->show();
示例10: json_decode
//Define Lastfm API calls
$lastfmApi = "http://ws.audioscrobbler.com/2.0/?method=user.gettopalbums&user=" . $request['user'] . "&period=" . $request['period'] . "&api_key=" . $config['api_key'] . "&limit={$limit}&format=json";
$validUser = "http://ws.audioscrobbler.com/2.0/?method=user.getinfo&user=" . $request['user'] . "&api_key=" . $config['api_key'] . "&format=json";
//Check if a valid user
$infoJson = json_decode(getJson($validUser));
//If an error is thrown, generate an error image and exit
if (isset($infoJson->{"error"})) {
header("Content-Type: image/png");
error_log($infoJson->{"message"} . " - " . $request['user']);
imagepng(errorImage($infoJson->{"message"}));
$sns = SnsClient::factory(array('credentials.cache' => $cache, 'region' => 'eu-west-1'));
$sns->publish(array('TopicArn' => 'arn:aws:sns:eu-west-1:346795263809:LastFM-Errors', 'Message' => $infoJson->{"message"} . " - " . $request['user'], 'Subject' => "Lastfm Error: " . $infoJson->{"error"}));
return;
}
//Get User's albums and generate a MD5 hash based on this
$json = getJson($lastfmApi);
$sns = SnsClient::factory(array('credentials.cache' => $cache, 'region' => 'eu-west-1'));
$sns->publish(array('TopicArn' => 'arn:aws:sns:eu-west-1:346795263809:LastFM-API-CAlls', 'Message' => $json, 'Subject' => $user . "s JSON API Call"));
$jsonhash = md5($json);
//Cache based on user set variables and JSON hash
$filename = "images/{$user}.{$period}.{$rows}.{$cols}.{$albumInfo}.{$plays}.{$jsonhash}";
//if a previous file exists - request is cached, serve from cache and exit
if (file_exists($filename)) {
header("Content-Type: image/jpeg");
error_log("Serving from cache - " . $filename);
echo file_get_contents($filename);
exit;
}
//otherwise carry on and getAlbums from LastFM.
$albums = getAlbums(json_decode($json));
//Pass the Albums to getArt to download the art into a $covers array
示例11: getJson
if ($info["state"] == 'SUCCESS') {
echo getJson('0', 'success', array('file' => getFileInfo($target . $info["name"], $ROOT)));
} else {
echo getJson('1', $info["state"], array('file' => getFileInfo($target . $info["name"], $ROOT)));
}
break;
case 'download':
$path = $ROOT . $target;
$info = getFileInfo($target, $ROOT);
downloadFile($path, $info['name']);
break;
case 'info':
echo getJson('0', 'success', array('file' => getFileInfo($target, $ROOT)));
break;
default:
echo getJson('1', 'unknow command');
break;
}
function listFile($dir, $ROOT)
{
if ($handle = opendir($ROOT . $dir)) {
$output = array();
$dir = $dir[strlen($dir) - 1] == '/' ? $dir : $dir . '/';
while (false !== ($item = readdir($handle))) {
if ($item != "." && $item != "..") {
$output[] = getFileInfo($dir . $item, $ROOT);
}
}
closedir($handle);
return $output;
} else {
示例12: header
<?php
header('Content-Type: application/json');
define('WEBSITE', 'http://www.studentenwerk-oldenburg.de/de');
define('OVERVIEW_URI', '/gastronomie/speiseplaene.html');
define('DETAILVIEW_URI', '/gastronomie/speiseplaene/%s.html');
define('OVERVIEW', isset($_GET['mensa']) ? FALSE : TRUE);
define('SCRIPT_URL', "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
require_once 'simple_html_dom.php';
require_once 'functions.php';
$output = '';
if (OVERVIEW) {
$url = WEBSITE . OVERVIEW_URI;
$output = getJson($url, '7 days');
} else {
$url = WEBSITE . sprintf(DETAILVIEW_URI, $_GET['mensa']);
$output = getJson($url, '120 minutes');
}
echo $output;
示例13: bindCacheSetting
function bindCacheSetting()
{
global $_FANWE;
$settings = array();
$js_settings = array();
$res = FDB::query("SELECT name,val,is_js FROM " . FDB::table('sys_conf') . " WHERE status = 1");
while ($data = FDB::fetch($res)) {
$name = strtolower($data['name']);
$settings[$name] = $data['val'];
if ($data['is_js'] == 1) {
$js_settings[$name] = $data['val'];
}
}
writeFile(PUBLIC_ROOT . './js/setting.js', 'var SETTING = ' . getJson($js_settings) . ';');
$pingJs = '';
//采集JS初始化
$pingJs = @file_get_contents(PUBLIC_ROOT . './js/demo.js');
$domain = 'var domain = "' . $_FANWE['site_url'] . '"; ';
$host_name = 'var hostName = "' . str_replace("http://", "", $_FANWE['site_url']) . '"; ';
$tpl_name = 'var tplName = "' . $_FANWE['setting']['site_tmpl'] . '"; ';
$yz_name = 'var global="TUPU";document[global]=document[global] || {};';
$im_ping_js = '';
$im_ping_js = $host_name . $domain . $tpl_name . $yz_name . $pingJs;
writeFile(PUBLIC_ROOT . './js/im.ping.js', $im_ping_js);
$config_file = @file_get_contents(PUBLIC_ROOT . 'config.global.php');
$config_file = trim($config_file);
$config_file = preg_replace("/[\$]config\\['time_zone'\\].*?=.*?'.*?'.*?;/is", "\$config['time_zone'] = '" . $settings['time_zone'] . "';", $config_file);
$config_file = preg_replace("/[\$]config\\['default_lang'\\].*?=.*?'.*?'.*?;/is", "\$config['default_lang'] = '" . $settings['default_lang'] . "';", $config_file);
@file_put_contents(PUBLIC_ROOT . 'config.global.php', $config_file);
unset($config_file);
$lang_arr = array();
$lang_files = array(FANWE_ROOT . './core/language/' . $settings['default_lang'] . '/template.lang.php', FANWE_ROOT . './tpl/' . $settings['site_tmpl'] . '/template.lang.php');
foreach ($lang_files as $lang_file) {
if (@(include $lang_file)) {
foreach ($lang as $lkey => $lval) {
$lang_pre = strtolower(substr($lkey, 0, 3));
if ($lang_pre == 'js_') {
$lang_key = substr($lkey, 3);
if ($lang_key != '') {
$lang_arr[$lang_key] = $lval;
}
}
}
}
}
writeFile(PUBLIC_ROOT . './js/lang.js', 'var LANG = ' . getJson($lang_arr) . ';');
clearDir(FANWE_ROOT . './public/data/tpl/css/');
clearDir(FANWE_ROOT . './public/data/tpl/js/');
$css_dir = FANWE_ROOT . './tpl/' . $settings['site_tmpl'] . '/css/';
$css_cache_dir = FANWE_ROOT . './public/data/tpl/css/';
$css_site_path = $_FANWE['site_root'] . 'tpl/' . $settings['site_tmpl'] . '/';
$directory = dir($css_dir);
while ($entry = $directory->read()) {
if ($entry != '.' && $entry != '..' && stripos($entry, '.css') !== false) {
$css_path = $css_dir . $entry;
$css_content = @file_get_contents($css_path);
$css_content = preg_replace("/\\.\\.\\//", $css_site_path, $css_content);
$css_cache_path = $css_cache_dir . '/' . $entry;
writeFile($css_cache_path, $css_content);
}
}
$directory->close();
FanweService::instance()->cache->saveCache('setting', $settings);
}
示例14: getCustomersByName
function getCustomersByName($customerName, $format)
{
global $apiId, $apiKey;
if ($format == "xml") {
return getXml($apiId, $apiKey, "Customers", "customerName={$customerName}");
} else {
return getJson($apiId, $apiKey, "Customers", "customerName={$customerName}");
}
}
示例15: getStockOnHand
function getStockOnHand($format)
{
global $apiId, $apiKey;
if ($format == "xml") {
return getXml($apiId, $apiKey, "StockOnHand", "");
} else {
return getJson($apiId, $apiKey, "StockOnHand", "pageSize=300");
}
}