Beispiel #1
0
<?php

require_once "xml2json/xml2json.php";
$url = $_GET['url'];
// Open the Curl session
$session = curl_init($url);
$postvars = '';
foreach ($_POST as $key => $value) {
    $postvars .= $key . '=' . $value . '&';
}
if ($postvars != '') {
    curl_setopt($session, CURLOPT_POST, true);
    curl_setopt($session, CURLOPT_POSTFIELDS, $postvars);
}
// Don't return HTTP headers. Do return the contents of the call
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// Make the call
$xml = curl_exec($session);
curl_close($session);
$json = xml2json::transformXmlStringToJson($xml);
echo $json;
 function TransformXmlToJson()
 {
     $jsonContents = xml2json::transformXmlStringToJson($this->xml);
     return $jsonContents;
 }
Beispiel #3
0
<?php

global $_W, $_GPC;
//check_shop_auth('http://120.26.212.219/api.php', $this -> pluginname);
ca('sale.enough.view');
$set = $this->getSet();
if (checksubmit('submit')) {
    ca('sale.enough.save');
    $data = is_array($_GPC['data']) ? $_GPC['data'] : array();
    $set['enoughfree'] = intval($data['enoughfree']);
    $set['enoughorder'] = round(floatval($data['enoughorder']), 2);
    $set['enoughareas'] = $data['enoughareas'];
    $set['enoughmoney'] = round(floatval($data['enoughmoney']), 2);
    $set['enoughdeduct'] = round(floatval($data['enoughdeduct']), 2);
    $this->updateSet($set);
    plog('sale.enough.save', '修改满额优惠');
    message('满额优惠设置成功!', referer(), 'success');
}
$areafile = IA_ROOT . "/addons/ewei_shop/data/areas";
$areas = json_decode(@file_get_contents($areafile), true);
if (!is_array($areas)) {
    require_once EWEI_SHOP_INC . 'json/xml2json.php';
    $file = IA_ROOT . "/addons/ewei_shop/static/js/dist/area/Area.xml";
    $content = file_get_contents($file);
    $json = xml2json::transformXmlStringToJson($content);
    $areas = json_decode($json, true);
    file_put_contents($areafile, $json);
}
load()->func('tpl');
include $this->template('enough');
Beispiel #4
0
merge, publish and distribute. This Software shall be used for Good, not Evil.

First Created on:
-----------------
Oct/04/2006

Last Modified on:
-----------------
Oct/07/2006
============================================================================================
*/
require_once "xml2json.php";
// Filename from where XML contents are to be read.
$testXmlFile = "";
// Read the filename from the command line.
if ($argc <= 1) {
    print "Please provide the XML filename as a command-line argument:\n";
    print "\tphp -f xml2json_test.php test1.xml\n";
    return;
} else {
    $testXmlFile = $argv[1];
}
//Read the XML contents from the input file.
file_exists($testXmlFile) or die('Could not find file ' . $testXmlFile);
$xmlStringContents = file_get_contents($testXmlFile);
$jsonContents = "";
// Convert it to JSON now.
// xml2json simply takes a String containing XML contents as input.
$jsonContents = xml2json::transformXmlStringToJson($xmlStringContents);
echo "JSON formatted output generated by xml2json:\n\n";
echo $jsonContents;
 function _throwError($error, $response_format)
 {
     Configure::write('debug', 0);
     $op = '<?xml version="1.0" encoding="UTF-8"?><response>' . $error . '</response>';
     if ($response_format == 'json') {
         App::import('vendor', 'xml2json', array('file' => 'xml2json/xml2json.php'));
         $jsonContents = xml2json::transformXmlStringToJson($op);
         echo $jsonContents;
     } else {
         //header("content-type: text/xml");
         echo $op;
     }
     exit;
 }
Beispiel #6
0
 public static function json($xml)
 {
     return xml2json::transformXmlStringToJson($xml);
 }
<?php

require_once "xml2json.php";
$file = utf16_to_utf8(file_get_contents($_FILES['file']['tmp_name']));
$log = fopen("log.txt", "a");
// fwrite($log, "starting\n");
// fwrite($log, "##" . $_FILES['file']['name'] . "##\n");
if (isPlist($_FILES['file']['name'])) {
    // fwrite($log, "is a plist\n");
    $postArgs = addFilenameAndType(xml2json::transformXmlStringToJson($file), $_FILES['file']['name'], "plist");
} else {
    if (isStrings($_FILES['file']['name'])) {
        // fwrite($log, "is a strings\n");
        $postArgs = transformStringsToJson($file, $_FILES['file']['name']);
    } else {
        if (isZip($_FILES['file']['name'])) {
            // fwrite($log, "is a zip\n");
            $postArgs = archiveToJson($file, $log);
        }
    }
}
fclose($log);
header("Content-Type: text/json");
// temporary fix
echo $postArgs;
function archiveToJson($zipFileContents, $log)
{
    $aFileName = "tmpArchive" . time() . ".zip";
    $theFile = fopen($aFileName, "w");
    // fwrite($log, "opened archive\n");
    fwrite($theFile, $zipFileContents);
Beispiel #8
0
function wfGetNetflixData($query = false, $callback = false, $count = 3)
{
    global $wgMemc;
    $query = urldecode($query);
    $netflix_api_key = WISE_netflix_api_key;
    $netflix_api_secret = WISE_netflix_api_secret;
    require_once '../common/OAuth.php';
    $test_consumer = new OAuthConsumer($netflix_api_key, $netflix_api_secret, NULL);
    $req_token = new OAuthConsumer("requestkey", "requestsecret", 1);
    $req_req = OAuthRequest::from_consumer_and_token($test_consumer, NULL, 'GET', 'http://api.netflix.com/catalog/titles', array("term" => $query, "expand" => "synopsis", "max_results" => $count));
    $req_req->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $test_consumer, NULL);
    $param_array = array();
    $params = preg_split("&", $req_req);
    foreach ($params as $key1) {
        $params2 = preg_split("=", $key1);
        $param_array[$params2[0]] = $params2[1];
    }
    $end_point_url = $req_req;
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $end_point_url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_TIMEOUT, 60);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    $xml = curl_exec($curl);
    $netflix_json = xml2json::transformXmlStringToJson($xml);
    return ($callback ? $callback . "(" : "") . $netflix_json . ($callback ? ");" : "");
}
 /**
  * getServiceResponse function.
  * 
  * @access public
  * @param mixed $param
  * @return void
  */
 function getServiceResponse($param)
 {
     $p = $this->getParameters($param);
     switch ($_REQUEST['bwsp_service']) {
         case 'getModelsIdByUniprotId':
             $this->rawResponse = $this->getModelsIdByUniprotId($p['uniprotId']);
             return true;
             break;
         case 'getModelByID':
             $this->rawResponse = $this->getModelByID($p['id']);
             return true;
             break;
     }
     $this->jsonResponse = xml2json::transformXmlStringToJson($this->rawResponse);
 }
    $url .= "&Operation=ItemSearch";
    $url .= "&AWSAccessKeyId=" . $amazonAWSAccessKeyId;
    $url .= "&AssociateTag=" . $amazonAssociateTag;
    $url .= "&ResponseGroup=Medium";
    $url .= "&SearchIndex=" . $q_search;
    if ($q_type) {
        $url .= "&IdType=" . $q_type;
        $url .= "&ItemId=" . $q_item;
        $url .= "&Keywords=" . urlencode($q_item);
    } else {
        $url .= "&Keywords=" . urlencode($q_item);
    }
    // sign
    $url = amazonSign($url, $amazonSecretAccessKey);
    // fetch the response and parse the results
    $curl_handle = curl_init();
    curl_setopt($curl_handle, CURLOPT_URL, $url);
    curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($curl_handle);
    if ($q_output == "raw" || $q_output == null) {
        header("Content-Type:text/xml");
        echo $data;
    } elseif ($q_output == "xml") {
        header("Content-Type:text/xml");
        echo amazonItemPrint($data, $q_num);
    } elseif ($q_output == "json") {
        header("Content-Type:application/json");
        echo xml2json::transformXmlStringToJson(amazonItemPrint($data, $q_num));
    }
}