Coder Social home page Coder Social logo

flex-twittersearch-widget's Introduction

flex-twittersearch-widget

This widget is for monitoring Tweets within a specific geographic area. It was designed for disaster response efforts. You can combine its capabilities with other FlexViewer widgets. It includes searching Twitter within a geographic area, applying multiple filters against search results, automatic refresh, and clustering of results on map.

####Main screen

App

####Settings screen

App

####Search results

App

##Installation

###Option 1

  1. Copy twittersearch directory from the download into the widgets folder of your ArcGIS Viewer for Flex directory in FlashBuilder. The path should be \widgets\twittersearch.

    • If you don't do this you will have lots of path errors when you try to run the widget.
    • If you don't have the the Viewer source code it can be downloaded here: https://github.com/ArcGIS/ArcGISViewerForFlex/tags
    • It's strongly recommended that you compile this widget with at least Adobe Flex SDK v4.6.
  2. Be sure to add twittersearch to config.xml and reference twittersearch/widgets/TwitterSearchWidget.swf, for example:

         <widget label="TwitterSearch"  x="850" y="100" preload="open" 
             icon="assets/images/i_twitter.png" 
             config="widgets/twittersearch/widgets/TwitterSearchWidget.xml"
             url="widgets/twittersearch/widgets/TwitterSearchWidget.swf"/>  
    
  3. Configure twittersearch.xml to point to the location of your TwitterSearch ouath proxy. The project won't work without this. These have been included with your download in the /oauthproxy directory.

  4. Install PHP OAuth proxy. As of May 2013, Twitter will require all applications to use OAuth authentication. Versions of the TwitterSearch widget prior to v4 used un-authenticated GET requests and will stop working as of May 2013. Here's the link to the Twitter Search API doc.

IMPORTANT: ONLY a PHP proxy is available as of v4.

NOTE: Mac users. You will have to seperately install Mcrypt libraries to test the proxy.

NOTE: Windows Users. I believe that the PHP for Windows installs the Mcrypt libraries automatically: http://windows.php.net/index.php.

The widget won't work without this OAuth proxy and you'll see an error when you try to run the widget. You do not have to recompile if you have the wrong proxy url set in the widgets config.xml. Simply change location in the file, save the file,then restart the application and the new proxy location should take effect. Sometimes, a user may have to flush their browser to ensure the changes took effect.

IMPORTANT: If you don't add a proxy directory, then when you go to run/debug the project it will throw an error. Once you set up the proxy this error will go away.

  1. In FlashBuilder, under Project > Properties > Flex Modules: be sure you add a reference to the TwitterSearch module.This is an easy-to-forget step. But, if you don't do it, then the widget won't launch.

  2. Copy as3corelib.swc from the root directory of the zip file into the lib directory of your Viewer project.

###Option #2: Deploy Immediately Option

The precompiled folder of the repo contains a precompiled version of the widget that's ready to be dropped onto a web server. You'll still need to configure twittersearch.xml, FlexViewer's config.xml, and set up the OAuth proxy.

##Configuring and Testing the OAuth Proxy (REQUIRED)

The proxy REQUIRES PHP and the Mcrypt library be installed. Mycrypt is typically installed when you use PHP for Windows. Mac users it might be easier to install PHP for Windows on a Windows Virtual Machine than go through the convolutions of installing Mycrypt on your Mac, or installing MAMP.

###Setting up Twitter Developer Account

  • You WILL need a Twitter Developer Account.
  • Sign into your Twitter Developer Account.
  • Hover over your Avatar (upper right hand side of page) and select "My Applications".
  • Select Create New Application.
  • The Application Website field needs the website of your organization.
  • The callback URL needs to be on a public website. You can still test locally even if you set this to a public website URL.
  • Under the "Details" tab, copy the Consumer Key and Consumer Secret and paste those into the config.php file.
  • Set the DOMAIN in config.php. Example for esri.com is ".esri.com".

###Configure the proxy

  • Run createKey.php to get your Key and IV. OAuth PHP cookies are encrypted by best practice. A copy of the encryption library is available in this repo and maintained here: https://github.com/andygup/php-cookie-encryption-lib.
  • Copy the Key and IV into config.php.
  • Set the timezone in config.php.
  • Set the OAUTH_COOKIE_DOMAIN and OAUTH_CALLBACK in config.php. The default settings in the file show you the settings for testing locally.
  • Run test.php. If everything is setup properly it should run with no errors.
  • Sign into OAuth using sign_in.php
  • Run the following command in your browser. If it fails to return values then something isn't set up correctly: [http://your_domain_name/oauthproxy/?cmd=search&geocode=34.26847173704432%2C-118.02937514220592%2C40mi&count=40&nocache=Thu%20Apr%204%2018](http:///oauthproxy/?cmd=search&geocode=34.26847173704432%2C-118.02937514220592%2C40mi&count=40&nocache=Thu%20Apr%204%2018)
  • Once this is configured you should be good to try and run the TwitterSearch widget inside FlexViewer.

If you simply can't get encryption to work then you can do the following (NOT RECOMMENDED and totally unsupported) steps. Most problems with encryption will stem from the Mcrypt library not being loaded.

  • index.php comment out lines 15 thru 18 as well as 68, 69 and 70. Uncomment line 73. You might also have to comment out the require_once that points to Encrypt.php.

    //$oauth_token = $encrypt->decrypt(base64_decode($access_token['oauth_token'])); echo "oauth ". (string)trim($oauth_token);
    //$oauth_token_secret = $encrypt->decrypt(base64_decode($access_token['oauth_token_secret'])); echo "\n\nsecret ". $oauth_token_secret."\n\n";
    //$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, (string)trim($oauth_token), (string)trim($oauth_token_secret));

    // Create a TwitterOauth object with consumer/user tokens. $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);

  • callback.php comment out the require_once pointing to Encrypt.php. Comment out lines 29, 30 and 31. Comment out lines 61 - 66.

##Minimum Requirements

[](Esri Tags: FlexViewer Flex Widget Twitter OAuth) [](Esri Language: ActionScript)

flex-twittersearch-widget's People

Contributors

andygup avatar

Watchers

Justin Farrow avatar James Cloos avatar

Forkers

andygup

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.