Example #1
0
 /**
  * Converts the Response object body to an array
  *
  * @return array
  */
 public function bodyToArray()
 {
     // Getting response content
     $jsonContent = $this->response->getContent();
     // Wrapping it into a Json reader object and convert it to array
     $jsonReader = new Json();
     return $jsonReader->fromString($jsonContent);
 }
Example #2
0
 public static function run()
 {
     header('Content-type: application/json');
     if (!isset($_GET["url"])) {
         echo json_encode(null);
         return;
     }
     $reader = new Json();
     $shariff = new Backend($reader->fromFile('shariff.json'));
     echo json_encode($shariff->get($_GET["url"]));
 }
 public function listenAction()
 {
     header('Content-type: application/json');
     $url = $this->getParam('url');
     if (empty($url)) {
         echo json_encode(null);
         return;
     }
     $configFile = \Pimcore\Config::locateConfigFile("shariff.php");
     if (is_file($configFile)) {
         $confArray = (include $configFile);
     } else {
         $reader = new Json();
         $confArray = $reader->fromFile(PIMCORE_PLUGINS_PATH . '/Shariff/config/shariff.json');
     }
     $shariff = new Backend($confArray);
     echo json_encode($shariff->get($url));
     exit;
 }
 public function createService(ServiceLocatorInterface $serviceManager)
 {
     $config = $serviceManager->get('Config');
     if (!isset($config['zf2_assetic'])) {
         throw new InvalidArgumentException('Missing zf2_assetic config key');
     }
     if (!isset($config['zf2_assetic']['assetManifestPath'])) {
         throw new InvalidArgumentException('Missing assetManifestPath config key');
     }
     $reader = new Json();
     try {
         $data = $reader->fromFile($config['zf2_assetic']['assetManifestPath']);
     } catch (\Zend\Config\Exception\RuntimeException $e) {
         throw new RuntimeException('Can\'t load asset manifest file', null, $e);
     }
     if (!isset($data['assets'])) {
         throw new RuntimeException('Asset manifest missing \'assets\' key');
     }
     return $data;
 }
Example #5
0
 /**
  * call and read specified configuration
  *
  * @param string $path
  * @param string $type
  * @return array
  */
 protected function configurationStrategy($path, $type)
 {
     $config = [];
     if (!file_exists($path)) {
         throw new \InvalidArgumentException('File ' . $path . 'don\'t exists.');
     }
     switch ($type) {
         case 'array':
             $config = (include_once $path);
             break;
         case 'ini':
             $reader = new Reader\Ini();
             $config = $reader->fromFile($path);
             break;
         case 'xml':
             $reader = new Reader\Xml();
             $config = $reader->fromFile($path);
             break;
         case 'json':
             $reader = new Reader\Json();
             $config = $reader->fromFile($path);
             break;
         case 'yaml':
             $reader = new Reader\Yaml(['Spyc', 'YAMLLoadString']);
             $config = $reader->fromFile($path);
             break;
     }
     return $config;
 }
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// just for MSIE 5
header("Pragma: no-cache");
require_once __DIR__ . '/vendor/autoload.php';
use Heise\Shariff\Backend;
use Zend\Config\Reader\Json;
header('Content-type: application/json');
// exit if no url is provided
if (!isset($_GET["url"])) {
    echo 'No URL provided!';
    return;
}
// if we have a json config file
if (is_readable(dirname(__FILE__) . '/shariff.json')) {
    $reader = new \Zend\Config\Reader\Json();
    $tmp = $reader->fromFile(dirname(__FILE__) . '/shariff.json');
}
// check, if user has changed it to his domain
if ($tmp['domain'] == 'www.example.com' || $tmp['domain'] == 'www.heise.de' || empty($tmp['domain'])) {
    $tmp['domain'] = $_SERVER['HTTP_HOST'];
}
// check mandatory services array
if (!is_array($tmp["services"])) {
    $tmp["services"] = array("0" => "GooglePlus", "1" => "Twitter", "2" => "Facebook", "3" => "LinkedIn", "4" => "Reddit", "5" => "Flattr", "6" => "StumbleUpon", "7" => "Pinterest", "8" => "Xing", "9" => "Tumblr");
}
// force a short init because we only need WP core
define('SHORTINIT', true);
// build the wp-load.php path
$wp_root_path = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
// if wp-load.php doesn't exist at $wp_root_path, then search for it.