本文整理汇总了PHP中get_response函数的典型用法代码示例。如果您正苦于以下问题:PHP get_response函数的具体用法?PHP get_response怎么用?PHP get_response使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_response函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: item_ajax_handler
function item_ajax_handler()
{
// Handle the ajax request
check_ajax_referer('item_drs');
$url = "https://repository.library.northeastern.edu/api/v1/files/";
if ($_POST['pid']) {
$url .= $_POST['pid'];
}
$data = get_response($url);
$data = json_decode($data, true);
if ($data['canonical_object'][0][1] == 'Video File' || $data['canonical_object'][0][1] == 'Audio File') {
$data['av_pid'] = $data['canonical_object'][0][0];
$data['av_pid'] = explode("/", $data['av_pid']);
$data['av_pid'] = end($data['av_pid']);
$data['encoded_av_pid'] = str_replace(':', '%3A', $data['av_pid']);
$data['av_dir'] = substr(md5("info:fedora/" . $data['av_pid'] . "/content/content.0"), 0, 2);
$data['av_type'] = $data['canonical_object'][0][0];
foreach ($data['content_objects'] as $key => $val) {
if ($val[1] == 'Master Image') {
$data['av_poster'] = $val[0];
}
}
if ($data['canonical_object'][0][1] == 'Video File') {
$data['av_provider'] = 'video';
$data['av_type'] = "MP4";
}
if ($data['canonical_object'][0][1] == 'Audio File') {
$data['av_provider'] = 'sound';
$data['av_type'] = "MP3";
}
}
wp_send_json(json_encode($data));
}
示例2: import_ajax_handler
function import_ajax_handler()
{
global $data;
$data = array();
$data['count'] = 0;
$data['existing_count'] = 0;
$data['site_url'] = site_url();
$data['objects'] = array();
// global $email;
// Handle the ajax request
check_ajax_referer('import_drs');
$collection_pid = $_POST['pid'];
$collection_pid = explode("/", $collection_pid);
$collection_pid = end($collection_pid);
$url = "https://repository.library.northeastern.edu/api/v1/export/" . $collection_pid . "?per_page=2&page=1";
$drs_data = get_response($url);
$json = json_decode($drs_data);
// $email = '';
if ($json->pagination->table->total_count > 0) {
$email .= $json->pagination->table->total_count;
for ($x = 1; $x <= $json->pagination->table->num_pages; $x++) {
$url = "https://repository.library.northeastern.edu/api/v1/export/" . $collection_pid . "?per_page=2&page=" . $x;
$drs_data = get_response($url);
$json = json_decode($drs_data);
drstk_get_image_data($json);
}
} else {
$data = json_decode($drs_data);
}
wp_send_json(json_encode($data));
}
示例3: get_this_breadcrumb
function get_this_breadcrumb($breadcrumb_url)
{
global $breadcrumb_html;
$breadcrumb_data = get_response($breadcrumb_url);
$breadcrumb_data = json_decode($breadcrumb_data);
$doc = $breadcrumb_data->response->response->docs[0];
parse_this_breadcrumb($doc);
}
示例4: main
function main($cids)
{
$url = 'http://www.789wz.com/Welcome/get_msg';
foreach ($cids as $cid) {
$response = get_response($url, $cid);
acces_log($cid);
}
acces_log(date("Y-m-d H:i:s"));
}
示例5: item_admin_ajax_handler
function item_admin_ajax_handler()
{
$data = array();
// Handle the ajax request
check_ajax_referer('item_admin_nonce');
$url = "https://repository.library.northeastern.edu/api/v1/files/" . $_POST['pid'];
$data = get_response($url);
$data = json_decode($data);
wp_send_json(json_encode($data));
}
示例6: get_item_title
function get_item_title()
{
global $item_pid, $data, $url;
$url = "https://repository.library.northeastern.edu/api/v1/files/" . $item_pid;
$data = get_response($url);
$data = json_decode($data);
if (check_for_bad_data()) {
return false;
}
echo $data->mods->Title[0];
}
示例7: breadcrumb_ajax_handler
function breadcrumb_ajax_handler()
{
// Handle the ajax request
$collection = drstk_get_pid();
check_ajax_referer('breadcrumb_drs');
$url = "https://repository.library.northeastern.edu/api/v1/search/" . $collection . "?";
if ($_POST['pid']) {
$url .= 'f["id"][]=' . $_POST['pid'];
}
$data = get_response($url);
$data = json_decode($data, true);
$data['site_url'] = site_url();
wp_send_json(json_encode($data));
}
示例8: browse_ajax_handler
function browse_ajax_handler()
{
// Handle the ajax request
global $errors;
check_ajax_referer('browse_drs');
$collection = drstk_get_pid();
if ($collection == '' || $collection == NULL) {
$data = array('error' => $errors['search']['missing_collection']);
$data = json_encode($data);
wp_send_json($data);
wp_die();
} elseif ($collection == "https://repository.library.northeastern.edu/collections/neu:1") {
$data = array('error' => $errors['search']['missing_collection']);
$data = json_encode($data);
wp_send_json($data);
wp_die();
} else {
if (isset($_POST['params']['collection'])) {
$url = "https://repository.library.northeastern.edu/api/v1/search/" . $_POST['params']['collection'] . "?";
} else {
$url = "https://repository.library.northeastern.edu/api/v1/search/" . $collection . "?";
}
if (isset($_POST['params']['q'])) {
$url .= "q=" . urlencode(sanitize_text_field($_POST['params']['q']));
}
if (isset($_GET['q'])) {
$url .= "q=" . urlencode(sanitize_text_field($_GET['q']));
}
if (isset($_POST['params']['per_page'])) {
$url .= "&per_page=" . $_POST['params']['per_page'];
}
if (isset($_POST['params']['page'])) {
$url .= "&page=" . $_POST['params']['page'];
}
if (isset($_POST['params']['f'])) {
foreach ($_POST['params']['f'] as $facet => $facet_val) {
$url .= "&f[" . $facet . "][]=" . urlencode($facet_val);
}
}
if (isset($_POST['params']['sort'])) {
$url .= "&sort=" . $_POST['params']['sort'];
}
$data = get_response($url);
wp_send_json($data);
wp_die();
}
}
示例9: drstk_add_tile_gallery
function drstk_add_tile_gallery()
{
check_ajax_referer('tile_ajax_nonce');
$col_pid = drstk_get_pid();
$url = "https://repository.library.northeastern.edu/api/v1/search/" . $col_pid . "?per_page=20";
if ($_POST['params']['q']) {
$url .= "&q=" . urlencode(sanitize_text_field($_POST['params']['q']));
}
if ($_POST['params']['page']) {
$url .= "&page=" . $_POST['params']['page'];
}
$data = get_response($url);
$json = json_decode($data);
if ($json->error) {
wp_send_json(json_encode("There was an error: " . $json->error));
return;
}
wp_send_json($data);
}
示例10: browse_ajax_handler
function browse_ajax_handler()
{
// Handle the ajax request
check_ajax_referer('browse_drs');
$collection = drstk_get_pid();
if ($collection == '' || $collection == NULL) {
$data = array('error' => 'Please enter a correct collection or community id in order to configure the search and browse functionality. Please proceed to /wp-admin to enter a Collection id');
$data = json_encode($data);
wp_send_json($data);
} elseif ($collection == "https://repository.library.northeastern.edu/collections/neu:1") {
$data = array('error' => 'Please enter a correct collection or community id in order to configure the search and browse functionality. Please proceed to /wp-admin to enter a Collection id');
$data = json_encode($data);
wp_send_json($data);
} else {
if ($_POST['params']['collection']) {
$url = "https://repository.library.northeastern.edu/api/v1/search/" . $_POST['params']['collection'] . "?";
} else {
$url = "https://repository.library.northeastern.edu/api/v1/search/" . $collection . "?";
}
if ($_POST['params']['q']) {
$url .= "q=" . urlencode(sanitize_text_field($_POST['params']['q']));
}
if ($_GET['q']) {
$url .= "q=" . urlencode(sanitize_text_field($_GET['q']));
}
if ($_POST['params']['per_page']) {
$url .= "&per_page=" . $_POST['params']['per_page'];
}
if ($_POST['params']['page']) {
$url .= "&page=" . $_POST['params']['page'];
}
if ($_POST['params']['f']) {
foreach ($_POST['params']['f'] as $facet => $facet_val) {
$url .= "&f[" . $facet . "][]=" . urlencode($facet_val);
}
}
if ($_POST['params']['sort']) {
$url .= "&sort=" . $_POST['params']['sort'];
}
$data = get_response($url);
wp_send_json($data);
}
}
示例11: get_json_data_from_neu_item
function get_json_data_from_neu_item()
{
check_ajax_referer('item_admin_nonce');
// The $_REQUEST contains all the data sent via ajax
if (isset($_REQUEST)) {
$item = $_REQUEST['item'];
//Setting the correct URL
$url = "https://repository.library.northeastern.edu/api/v1/files/" . $item;
//Adding response to data
$data = get_response($url);
$json = json_decode($data);
if (isset($json->error)) {
wp_send_json(json_encode("There was an error: " . $json->error));
return;
}
//returning json
echo wp_send_json($json);
// debugging purposes
// print_r($_REQUEST);
}
die;
}
示例12: get_response
<?php
function get_response($URL, $context)
{
/* Initializing CURL */
$curlHandle = curl_init();
/* The URL to be downloaded is set */
curl_setopt($curlHandle, CURLOPT_URL, $URL);
curl_setopt($curlHandle, CURLOPT_HEADER, false);
curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $context);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
/* Now execute the CURL, download the URL specified */
$response = curl_exec($curlHandle);
return $response;
}
$data = array('title' => 'abc', 'content' => 'Testing', 'status' => '4', 'date_time' => time());
$_json = json_encode($data);
echo get_response('http://127.0.0.1/dev/jd/github/wp01/insert_data.php', $_json);
示例13: drstk_tiles
function drstk_tiles($atts)
{
$imgs = explode(", ", $atts['id']);
$img_html = "";
foreach ($imgs as $img) {
$url = "https://repository.library.northeastern.edu/api/v1/files/" . $img;
$data = get_response($url);
$data = json_decode($data);
$type = $atts['type'];
if (!$data->error) {
$pid = $data->pid;
if (isset($atts['image-size'])) {
$num = $atts['image-size'] - 1;
} else {
$num = 4;
}
$thumbnail = $data->thumbnails[$num];
if (isset($atts['metadata'])) {
$img_metadata = '';
$metadata = explode(",", $atts['metadata']);
foreach ($metadata as $field) {
$this_field = $data->mods->{$field};
if (isset($this_field[0])) {
$img_metadata .= $this_field[0] . "<br/>";
}
}
}
if ($type == 'pinterest') {
$img_html .= "<div class='brick'><a href='" . site_url() . "/item/" . $pid . "'><img src='" . $thumbnail . "'></a><div class='info'><a href='" . site_url() . "/item/" . $pid . "'>" . $img_metadata . "</a>";
}
if ($type == 'even-row' || $type == 'square') {
$img_html .= "<div class='cell' data-thumbnail='" . $thumbnail . "'><div class='info'><a href='" . site_url() . "/item/" . $pid . "'>" . $img_metadata . "</a>";
}
$img_html .= "<div class='hidden'>";
$meta = $data->mods;
foreach ($meta as $field) {
if (is_array($field)) {
foreach ($field as $field_val) {
$img_html .= $field_val . "<br/>";
}
} else {
$img_html .= $field[0] . "<br/>";
}
}
$img_html .= "</div>";
$img_html .= "</div></div>";
} else {
$img_html = "There was an error";
}
}
$shortcode = "<div class='freewall' id='freewall' data-type='" . $type . "'";
if (isset($atts['cell-height'])) {
$shortcode .= " data-cell-height='" . $atts['cell-height'] . "'";
} else {
$shortcode .= " data-cell-height='200'";
}
if (isset($atts['cell-width'])) {
$shortcode .= " data-cell-width='" . $atts['cell-width'] . "'";
} else {
$shortcode .= " data-cell-width='200'";
}
if (isset($atts['text-align'])) {
$shortcode .= " data-text-align='" . $atts['text-align'] . "'";
} else {
$shortcode .= " data-text-align='center'";
}
$shortcode .= ">" . $img_html . "</div>";
return $shortcode;
}
示例14: list
<?php
require "settings.php";
require "functions.php";
// Split the variable into two, $domain & $port.
list($domain, $port) = filter_domain($_GET["domain"]);
// Check the site and get the response code.
$data = get_response($domain, $port);
// Caluate and format the time taken to connect.
$time = round($data["time"], 3);
$id = gen_id($data);
$title = gen_title($id, $domain);
$html = gen_html($id, $domain, $port, $time, $data["code"]);
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title><?php
echo $title . " // isitup.org";
// display the dynamic title
?>
</title>
<!-- Hi r/ProgrammerHumor :wave:! -->
<!-- Meta Info -->
<meta name="description" content="The availability results for <?php
echo $domain;
?>
示例15: get_response
<?php
/*
* API Pública educ.ar
*
* Ejemplo de llamado a endpoint: Obtención de capitulos de una serie
*
*/
$service_url = 'https://labs.educ.ar/1.0/videos';
$api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$fields = '*';
$filters = ['serie' => 'Ciencia vs. Ficción'];
$params = ['app_key' => $api_key, 'fields' => $fields, 'filters' => $filters, 'pretty' => true, 'limit' => 50];
function get_response($url)
{
$options = array(CURLOPT_RETURNTRANSFER => false, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 10, CURLOPT_ENCODING => "", CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120);
$url = str_replace(" ", "%20", $url);
$ch = curl_init($url);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
if (!function_exists('curl_version')) {
die('Se necesita tener instalada la extensión cURL');
}
$request = $service_url . '/' . json_encode($params, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
echo $request . "\n";
$response = get_response($request);
echo $response;