GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - suncat2000/TWCDataBundle: Symfony2 bundle for working with The Weather Channel API

BranchesTags
Open more actions menu

Latest commit

 

History

17 Commits
17 Commits

Folders and files

NameName
Last commit message
Last commit date
ApiData
ApiData
 
 
DependencyInjection
DependencyInjection
 
 
Exception
Exception
 
 
Resources/config
Resources/config
 
 
README.md
README.md
 
 
TWCDataBundle.php
TWCDataBundle.php
 
 

Repository files navigation

TWCDataBundle

Symfony2 bundle for working with The Weather Channel API

Introduction

This Bundle enables integration The Weather Channel API.

Note: Only /data/... resource api

Installation

  1. Add this bundle and kriswallsmith Buzz library to your project as Git submodules:

     $ git submodule add git://github.com/kriswallsmith/Buzz.git vendor/buzz
     $ git submodule add git://github.com/suncat2000/TWCDataBundle.git vendor/bundles/SunCat/TWCDataBundle
    
  2. Register the namespace Buzz & SunCat to your project's autoloader bootstrap script:

     //app/autoload.php
     $loader->registerNamespaces(array(
           // ...
           'Buzz'      => __DIR__.'/../vendor/buzz/lib',
           'SunCat'    => __DIR__.'/../vendor/bundles',
           // ...
     ));
    
  3. Add this bundle to your application's kernel:

     //app/AppKernel.php
     public function registerBundles()
     {
         return array(
             // ...
             new SunCat\TWCDataBundle\TWCDataBundle(),
             // ...
         );
     }
    
  4. Configure the twc_data service in your YAML configuration:

       #app/config/config.yml
       twc_data:
           apikey: your_api_key
           format: json        # or xml; optional, default: json
           units: m            # or s; optional, default: m
           locale: en_GB       # optional, default: en_GB
           country: UK         # optional, default: UK
    

Usage example

<?php
// src/Acme/YourBundle/Command/LocSearchCommand.php

        class LocSearchCommand extends ContainerAwareCommand
        {
            /**
             * @see Command
             */
            protected function configure()
            {
                $this
                    ->setName('weather:locsearch')
                    ->setDescription('Get location ID of city by city name')
                    ->addOption('city', 0, InputOption::VALUE_REQUIRED, 'City name')
                    ->setHelp(<<<EOF
        The <info>weather:locsearch</info> command get location ID.
        
        <info>php app/console weather:locsearch --city=london</info>
        
        EOF
                    )
                ;
            }

            /**
             * {@inheritdoc}
             */
            protected function execute(InputInterface $input, OutputInterface $output)
            {
                $twcData = $this->getContainer()->get('twc_data.api_data');
                $twcData->setCommand('locsearch');
                $cityName = $input->getOption('city');

                if(!$cityName){
                    throw new \Exception('Enter city name');
                }

                $twcData->setResourcePart($cityName);
                $data = $twcData->getData();

                //
                // put your code
                //
            }

        }

Run command:

        php app/console weather:locsearch --city=london

Query string parameters to TWC API:

        $twcData->setCountry('UK');
        $twcData->enabledCountry(false); // disable `country` param in query string to TWC API
        $twcData->setParams(array('day' => '0,1,2'));
        $twcData->setParams(array('start' => 1293840000, 'end' => 1296518399));

The Weather Channel® API Implementation Guide

Support & Download

About

Symfony2 bundle for working with The Weather Channel API

Resources

Readme
Activity

Stars

4 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.