本文整理匯總了PHP中phpQuery::parseJSON方法的典型用法代碼示例。如果您正苦於以下問題:PHP phpQuery::parseJSON方法的具體用法?PHP phpQuery::parseJSON怎麽用?PHP phpQuery::parseJSON使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phpQuery
的用法示例。
在下文中一共展示了phpQuery::parseJSON方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
function __construct($data)
{
$pq = null;
include_once dirname(__FILE__) . '/../phpQuery/phpQuery.php';
if (file_exists(dirname(__FILE__) . '/jQueryServer.config.php')) {
include_once dirname(__FILE__) . '/jQueryServer.config.php';
if ($jQueryServerConfig) {
$this->config = array_merge_recursive($this->config, $jQueryServerConfig);
}
}
if ($this->config['refererMustMatch']) {
foreach ($this->config['allowedRefererHosts'] as $i => $host) {
if ($host == '.') {
$this->config['allowedRefererHosts'][$i] = $_SERVER['HTTP_HOST'];
}
}
$referer = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
$authorized = $referer && in_array($referer, $this->config['allowedRefererHosts']);
if (!$authorized) {
throw new Exception("Host '{$_SERVER['HTTP_REFERER']}' not authorized to make requests.");
return;
}
}
// phpQueryClass::$debug = true;
// if (! function_exists('json_decode')) {
// include_once(dirname(__FILE__).'/JSON.php');
// $this->json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
// }
// $data = $this->jsonDecode($data);
$data = phpQuery::parseJSON($data);
// load document (required for first $data element)
if (is_array($data[0]) && isset($data[0]['url'])) {
$this->options = $data[0];
$ajax = $this->options;
$this->calls = array_slice($data, 1);
$ajax['success'] = array($this, 'success');
phpQuery::ajax($ajax);
} else {
throw new Exception("URL needed to download content");
break;
}
}