• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Services_JSON类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Services_JSON的典型用法代码示例。如果您正苦于以下问题:PHP Services_JSON类的具体用法?PHP Services_JSON怎么用?PHP Services_JSON使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Services_JSON类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: getResource

 public function getResource()
 {
     $resources = JRequest::getVar('resource');
     if (!is_array($resources)) {
         header('Content-type: text/x-json; UTF-8');
         echo '[]';
         exit;
     }
     foreach ($resources as &$resource) {
         $resource = (object) $resource;
         switch ($resource->type) {
             case 'language':
                 $resource->content = JText::_(strtoupper($resource->name));
                 break;
             case 'view':
                 $template = Komento::getTheme();
                 $out = $template->fetch($resource->name . '.ejs');
                 if ($out !== false) {
                     $resource->content = $out;
                 }
                 break;
         }
     }
     Komento::getClass('json', 'Services_JSON');
     header('Content-type: text/x-json; UTF-8');
     $json = new Services_JSON();
     echo $json->encode($resources);
     exit;
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:29,代码来源:foundry.php


示例2: output

 private function output($response)
 {
     include_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'json.php';
     $json = new Services_JSON();
     echo $json->encode($response);
     exit;
 }
开发者ID:Tommar,项目名称:vino2,代码行数:7,代码来源:media.php


示例3: genJSON

 function genJSON()
 {
     $this->fillMyArrays();
     $this->oJSONObject = new BxDolPFMAreaJSONObj($this);
     $oJSONConv = new Services_JSON();
     return $oJSONConv->encode($this->oJSONObject);
 }
开发者ID:Arvindvi,项目名称:dolphin,代码行数:7,代码来源:BxDolPFM.php


示例4: decode

 /**
  * Transforma el texto enviado en formato JSON a un objeto PHP
  *
  * @param string $html texto JSON a decodear
  * @return object objeto PHP
  */
 public function decode($html)
 {
     //         include_once("classes/JSON.class.php");
     $json = new Services_JSON();
     $data = stripslashes($html);
     return $json->decode($data);
 }
开发者ID:rodolfobais,项目名称:proylecturademo,代码行数:13,代码来源:Ajax.class.php


示例5: get_json

 function get_json($data, $status = 'ok')
 {
     // Include a status value with the response
     if (is_array($data)) {
         $data = array_merge(array('status' => $status), $data);
     } else {
         if (is_object($data)) {
             $data = get_object_vars($data);
             $data = array_merge(array('status' => $status), $data);
         }
     }
     $data = apply_filters('json_api_encode', $data);
     if (function_exists('json_encode')) {
         // Use the built-in json_encode function if it's available
         return json_encode($data);
     } else {
         // Use PEAR's Services_JSON encoder otherwise
         if (!class_exists('Services_JSON')) {
             $dir = gb_json_api_dir();
             require_once "{$dir}/library/JSON.php";
         }
         $json = new Services_JSON();
         return $json->encode($data);
     }
 }
开发者ID:simplon-emmanuelD,项目名称:Simplon-INESS,代码行数:25,代码来源:response.php


示例6: create_form_token_json

function create_form_token_json($form_id)
{
    global $class_path;
    include_once $class_path . 'lgpl/Services_JSON.class.php';
    $json_encoder = new Services_JSON();
    return $json_encoder->encode(create_form_token_array($form_id));
}
开发者ID:ragulka,项目名称:Saurus-CMS-Community-Edition,代码行数:7,代码来源:port.inc.php


示例7: send

 /**
  * Send the HTTP request via cURL
  *
  * @return SiftResponse
  */
 public function send()
 {
     $json = new Services_JSON();
     $propertiesString = http_build_query($this->properties);
     $curlUrl = $this->url;
     if ($this->method == self::GET) {
         $curlUrl .= '?' . $propertiesString;
     }
     // Mock the request if self::$mock exists
     if (self::$mock) {
         if (self::$mock['url'] == $curlUrl && self::$mock['method'] == $this->method) {
             return self::$mock['response'];
         }
         return null;
     }
     // Open and configure curl connection
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_URL, $curlUrl);
     curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
     if ($this->method == self::POST) {
         $jsonString = $json->encodeUnsafe($this->properties);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonString);
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($jsonString), 'User-Agent: SiftScience/v' . SiftClient::API_VERSION . ' sift-php/' . SiftClient::VERSION));
     }
     // Send the request using curl and parse result
     $result = curl_exec($ch);
     $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     // Close the curl connection
     curl_close($ch);
     return new SiftResponse($result, $httpStatusCode, $this);
 }
开发者ID:caomw,项目名称:sift-php,代码行数:38,代码来源:SiftRequest.php


示例8: getFiltersFor

 function getFiltersFor($msg, $id = null)
 {
     $json = new Services_JSON();
     if ($id !== null) {
         $this->id = $id;
     }
     $this->find();
     $res = array();
     while ($this->fetch()) {
         $fltrs = $json->decode($this->filter);
         // Serach for "from" and "subject"
         foreach ($fltrs as $f) {
             $from = !isset($f->from) || trim($f->from) == "";
             $subj = !isset($f->subject) || trim($f->subject) == "";
             if ($from && $subj) {
                 continue;
             }
             if (!$from) {
                 $from = strpos($msg->from, $f->from) !== false;
             }
             if (!$subj) {
                 $subj = strpos($msg->subject, $f->subject) !== false;
             }
             if ($from && $subj) {
                 $res[] = $this->toArray();
                 break;
             }
         }
     }
     return $res;
 }
开发者ID:rivetweb,项目名称:old-python-generators,代码行数:31,代码来源:Filter.php


示例9: run

 public function run()
 {
     require_once _lms_ . '/lib/lib.kbres.php';
     $kbres = new KbRes();
     $data = false;
     if ($this->res_id > 0) {
         $data = $kbres->getResource($this->res_id, true, true);
     } else {
         if (!empty($this->r_item_id) && !empty($this->r_type)) {
             $data = $kbres->getResourceFromItem($this->r_item_id, $this->r_type, $this->r_env, true, true);
         }
     }
     if ($data == false) {
         $data = array('res_id' => 0, 'r_name' => '', 'original_name' => '', 'r_desc' => '', 'r_item_id' => $this->r_item_id, 'r_type' => $this->r_type, 'r_env' => $this->r_env, 'r_env_parent_id' => $this->r_env_parent_id, 'r_param' => $this->r_param, 'r_alt_desc' => '', 'r_lang' => !empty($this->language) ? $this->language : getLanguage(), 'force_visible' => 0, 'is_mobile' => 0, 'folders' => array(), 'tags' => array());
     }
     if (!empty($this->original_name)) {
         $data['original_name'] = $this->original_name;
     }
     $c_folders = array_keys($data['folders']);
     unset($data['folders']);
     $c_tags = $data['tags'];
     unset($data['tags']);
     $json = new Services_JSON();
     $this->render('kbcategorize', array('selected_node' => $this->_getSelectedNode(), 'back_url' => $this->back_url, 'form_url' => $this->form_url, 'form_extra_hidden' => $this->form_extra_hidden, 'data' => $data, 'c_folders' => $c_folders, 'c_tags_json' => $json->encode(array_values($c_tags)), 'all_tags_json' => $json->encode(array_values($kbres->getAllTags()))));
 }
开发者ID:abhinay100,项目名称:forma_app,代码行数:25,代码来源:lib.kbcategorize.php


示例10: HTTP_GET

 function HTTP_GET()
 {
     $json = new paloSantoJSON();
     $pCore_calendar = new core_Calendar();
     $fields = isset($_GET["fields"]) ? $_GET["fields"] : NULL;
     if (is_null($fields)) {
         header("HTTP/1.1 400 Bad Request");
         $error = "You need to specify by GET the parameter \"fields\"";
         $json->set_status("ERROR");
         $json->set_error($error);
         return $json->createJSON();
     }
     $result = $pCore_calendar->getHash($fields);
     if ($result === FALSE) {
         $error = $pCore_calendar->getError();
         if ($error["fc"] == "DBERROR") {
             header("HTTP/1.1 500 Internal Server Error");
         } else {
             header("HTTP/1.1 400 Bad Request");
         }
         $json->set_status("ERROR");
         $json->set_error($error);
         return $json->createJSON();
     } else {
         $json = new Services_JSON();
         return $json->encode($result);
     }
 }
开发者ID:netconstructor,项目名称:elastix-mt-gui,代码行数:28,代码来源:VerifyEventsIntegrity.class.php


示例11: getData

 /**
  * It is specific implementation of ancestor method getData()
  *
  * @return <String> JSON represantation of given data.
  */
 public function getData()
 {
     $attributes = $this->solveData();
     $this->jsonObject['attributes'] = $attributes;
     $interestMeasure = $this->solveInterestMeasures();
     $this->jsonObject['interestMeasures'] = $interestMeasure;
     $this->solveNumberBBA();
     $this->solveDepthNesting();
     $this->solveMoreRules();
     $interestMeasure = $this->domFL->getElementsByTagName("InterestMeasures")->item(0);
     $bba = $this->domFL->getElementsByTagName("BasicBooleanAttribute")->item(0);
     $threshold = "optional";
     $coefficient = "optional";
     if ($interestMeasure->getAttribute("threshold") != "") {
         $threshold = $interestMeasure->getAttribute("threshold");
     }
     if ($bba->getAttribute("coefficient") != "") {
         $coefficient = $bba->getAttribute("coefficient");
     }
     $this->jsonObject['imThreshold'] = $threshold;
     $this->jsonObject['attrCoef'] = $coefficient;
     $posCoef = $this->solvePosCoef();
     $this->jsonObject['possibleCoef'] = $posCoef;
     if ($this->domER != null) {
         $this->solveExistingRules();
     } else {
         $this->jsonObject['rules'] = 0;
     }
     $this->jsonObject['lang'] = $this->lang;
     $json = new Services_JSON();
     return $json->encode($this->jsonObject);
 }
开发者ID:KIZI,项目名称:sewebar-cms,代码行数:37,代码来源:GetDataARBuilderQuery.php


示例12: getUserData

function getUserData($id)
{
    $user = new AMP_User_Profile(AMP_registry::getDbcon(), $id);
    if ($user) {
        $data = array();
        $data['Email'] = $user->getData('Email');
        $data['First_Name'] = $user->getData('First_Name');
        $data['Last_Name'] = $user->getData('Last_Name');
        $data['Phone'] = $user->getData('Phone');
        $data['Company'] = $user->getData('Company');
        $data['City'] = $user->getData('City');
        $data['Country'] = $user->getData('Country');
        $data['custom1'] = $user->getData('custom1');
        $data['custom3'] = $user->getData('custom3');
        $data['custom4'] = $user->getData('custom4');
        $message = array();
        $message['type'] = 'good';
        $message['text'] = 'Success';
        $json = new Services_JSON();
        $json_data = array('data' => $data, 'message' => $message, 'success' => true);
        $output = $json->encode($json_data);
        return $output;
    } else {
        $message = array();
        $message['type'] = 'bad';
        $message['text'] = 'Unrecognized User ID';
        $json_data = array('message' => $message);
        $output = $json->encode($json_data);
        return $output;
    }
}
开发者ID:radicaldesigns,项目名称:winonline,代码行数:31,代码来源:user.submit.php


示例13: smarty_function_json

/**
 * Smarty {json} plugin
 *
 * Type:     function
 * Name:     json
 * Purpose:  fetch json file and  assign result as a template variable (array) 
 * @param url (url to fetch)
 * @param assign (element to assign to)
 * @return array|null if the assign parameter is passed, Smarty assigns the
 *                     result to a template variable
 */
function smarty_function_json($params, &$smarty)
{
    if (empty($params['url'])) {
        $smarty->_trigger_fatal_error("[json] parameter 'url' cannot be empty");
        return;
    }
    $content = array();
    $data = file_get_contents($params['url']);
    if (empty($data)) {
        return false;
    }
    if (!is_callable('json_decode')) {
        require_once 'JSON.php';
        $json = new Services_JSON();
        $content = $json->decode(trim(file_get_contents($params['url'])));
    } else {
        $content = json_decode(trim(file_get_contents($params['url'])));
    }
    if ($params['debug'] === true) {
        echo "<pre>";
        print_r($content);
        echo "</pre>";
    }
    if (!empty($params['assign'])) {
        $smarty->assign($params['assign'], $content);
    } else {
        return $content;
    }
}
开发者ID:juliotak,项目名称:iahx-opac,代码行数:40,代码来源:function.json.php


示例14: loginTeacher

 static function loginTeacher($class, $pass, $ignoreNonexistent = false)
 {
     $json = new Services_JSON();
     if (!$class) {
         return "クラス名を入力してください。";
     }
     if (!$pass) {
         return "パスワードを入力してください。";
     }
     if (!file_exists("fs/home/{$class}") && !$ignoreNonexistent) {
         return "存在しないクラスIDが入力されています。";
     }
     if (preg_match('/^[a-zA-Z0-9\\-_]+$/', $pass)) {
         $fp = fopen("user/list.txt", "r");
         while ($line = fgets($fp)) {
             $classlist = $json->decode($line);
             if ($classlist["classid"] == $class) {
                 break;
             }
         }
         fclose($fp);
         if (isset($classlist) && $classlist["pass"] == $pass) {
             // Success
             MySession::set("class", $class);
             MySession::set("user", self::TEACHER);
             setcookie("class", $class, time() + 60 * 60 * 24 * 30);
             return true;
         } else {
             return "クラスIDかパスワードが間違っています。";
         }
     } else {
         return "パスワードは半角英数とハイフン、アンダースコアだけが使えます。";
     }
 }
开发者ID:hoge1e3,项目名称:jslesson,代码行数:34,代码来源:auth.php


示例15: __construct

 public function __construct($result, $httpStatusCode, $request)
 {
     if (function_exists('json_decode')) {
         $this->body = json_decode($result, true);
     } else {
         require_once dirname(__FILE__) . '/Services_JSON-1.0.3/JSON.php';
         $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
         $this->body = $json->decode($result);
     }
     $this->httpStatusCode = $httpStatusCode;
     // If there is an error we want to build out an error string.
     if ($this->httpStatusCode !== 200) {
         $this->error = $this->body['error'];
         $this->errorMessage = $this->error . ': ' . $this->body['description'];
         if (array_key_exists('issues', $this->body)) {
             $this->errorIssues = $this->body['issues'];
             foreach ($this->errorIssues as &$issue) {
                 $this->errorMessage .= array_search($issue, $this->errorIssues) . ': ' . $issue;
             }
             unset($issue);
         }
     }
     if (array_key_exists('request', $this->body)) {
         $this->request = $this->body['request'];
     } else {
         $this->request = null;
     }
     $this->request = $request;
     $this->result = $result;
 }
开发者ID:siftscience,项目名称:sift-partner-php,代码行数:30,代码来源:SiftResponse.php


示例16: decode

 function decode($str)
 {
     //$lib='native';
     // $lib='services_JSON';
     // $lib='jsonrpc';
     // dirty trick to correct bad json for photos
     //$str = preg_replace('/\t} {/','}, {', $str);
     // remove trailing ,
     //$str = preg_replace('/,[ \r\n\t]+}/',' }', $str);
     // echo "Using $lib<BR>";
     // echo $str;
     if (function_exists('json_decode') && JSON_LIB_DECODE == 'native') {
         $arr = json_decode($str, true);
     } else {
         if (JSON_LIB_DECODE == 'services_JSON') {
             require_once dirname(__FILE__) . '/json.php';
             $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
             $arr = $json->decode($str);
         } else {
             if (JSON_LIB_DECODE == 'jsonrpc') {
                 require_once dirname(__FILE__) . '/jsonrpc/xmlrpc.php';
                 require_once dirname(__FILE__) . '/jsonrpc/jsonrpc.php';
                 $GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
                 //require_once dirname(__FILE__).'/jsonrpc/json_extension_api.php';
                 //$arr=json_decode($str, true);
                 $value = php_jsonrpc_decode_json($str);
                 if ($value) {
                     $arr = php_jsonrpc_decode($value, array());
                 }
             }
         }
     }
     // print_r($arr);
     return $arr;
 }
开发者ID:Peter2121,项目名称:leonardoxc,代码行数:35,代码来源:CL_json.php


示例17: json

function json($file)
{
    global $fs, $word, $around;
    $j = new Services_JSON();
    $a = explode("T", $word);
    $date = preg_replace("/-/", "/", $a[0]);
    $time = $a[1];
    echo "{$time} ---  {$date}<BR>";
    $lines = explode("\n", $fs->getContent("{$file}-data.log"));
    $a = array();
    $around = $around / 10;
    $found = false;
    foreach ($lines as $line) {
        $e = $j->decode($line);
        if ($e) {
            $a[] = toHTML($e);
            //echo $e["date"]." ".$e["time"]. "<BR>";
            if ($found) {
                if (count($a) > $around * 2) {
                    break;
                }
            } else {
                if (count($a) > $around) {
                    array_shift($a);
                }
                if ($e["date"] == $date && $e["time"] == $time) {
                    array_push($a, "<a name='center'/><font color=red>-----------------------------------</font><BR>");
                    $found = TRUE;
                }
            }
        }
    }
    print join("<BR>", $a);
}
开发者ID:hoge1e3,项目名称:jslesson,代码行数:34,代码来源:grep.php


示例18: make_short_url

 function make_short_url($restURL)
 {
     $out = "GET " . $restURL . " HTTP/1.1\r\n";
     $out .= "Host: api.bit.ly\r\n";
     $out .= "Content-type: application/x-www-form-urlencoded\r\n";
     $out .= "Connection: Close\r\n\r\n";
     $handle = @fsockopen('api.bit.ly', 80, $errno, $errstr, 30);
     fwrite($handle, $out);
     $body = false;
     $contents = '';
     while (!feof($handle)) {
         $return = fgets($handle, 1024);
         if ($body) {
             $contents .= $return;
         }
         if ($return == "\r\n") {
             $body = true;
         }
     }
     fclose($handle);
     $json = new Services_JSON();
     $data = $json->decode($contents);
     //for issues with unable to authenticate error, somehow they return errors instead of error.
     if (!isset($data->status_code)) {
         return false;
     }
     if ($data->status_code != '200') {
         return false;
     }
     return $data->data->url;
 }
开发者ID:Tommar,项目名称:vino2,代码行数:31,代码来源:urlshortener.php


示例19: __construct

 public function __construct($result, $httpStatusCode, $request)
 {
     $this->body = null;
     $this->apiStatus = null;
     $this->apiErrorMessage = null;
     if (function_exists('json_decode')) {
         $this->body = json_decode($result, true);
     } else {
         require_once dirname(__FILE__) . '/Services_JSON-1.0.3/JSON.php';
         $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
         $this->body = $json->decode($result);
     }
     $this->httpStatusCode = $httpStatusCode;
     $this->request = $request;
     $this->rawResponse = $result;
     // Only attempt to get our response body if the http status code expects a body
     if (!in_array($this->httpStatusCode, array(204, 304))) {
         $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
         $this->body = $json->decode($result);
         // NOTE: Responses from /v3 endpoints don't contain status or error_message.
         if (array_key_exists('status', $this->body)) {
             $this->apiStatus = intval($this->body['status']);
         }
         if (array_key_exists('error_message', $this->body)) {
             $this->apiErrorMessage = $this->body['error_message'];
         }
     }
 }
开发者ID:siftscience,项目名称:sift-php,代码行数:28,代码来源:SiftResponse.php


示例20: index

 function index($params)
 {
     $search_criteria = array("sort" => "date DESC");
     if (!empty($this->search_for_payments)) {
         $search_criteria = array_merge($search_criteria, $this->search_for_payments);
     }
     $this->data->payments = Payment::getMany($search_criteria);
     if (!empty($params['spokes'])) {
         $spokes_data = $this->data->payments;
         $rows = array();
         foreach ($spokes_data as $data_item) {
             $rows[] = $data_item->to_spokes();
         }
         $json = new Services_JSON();
         $this->response = array('body' => $json->encode($rows));
         if (!empty($params['callback'])) {
             $this->response['body'] = $params['callback'] . '(' . $this->response['body'] . ')';
         }
         return;
     }
     $this->data->search_payment = new Payment();
     $this->data->search_payment->set($search_criteria);
     $this->data->new_payment = new Payment();
     $this->data->new_payment->set(array('date' => date('Y-m-d')));
 }
开发者ID:radicaldesigns,项目名称:gtd,代码行数:25,代码来源:PaymentController.php



注:本文中的Services_JSON类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Sesion类代码示例发布时间:2022-05-23
下一篇:
PHP Services类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap