CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Pre-installation Questions (Moderator: Dave Greenberg) »
  • Status of Sunlight Congressional Data integration in CiviCRM 2?
Pages: [1]

Author Topic: Status of Sunlight Congressional Data integration in CiviCRM 2?  (Read 4382 times)

markstos

  • I’m new here
  • *
  • Posts: 1
  • Karma: 0
Status of Sunlight Congressional Data integration in CiviCRM 2?
March 07, 2008, 08:40:09 am
Hello,

I'm evaluating CiviCRM for an east coast watershed protection group. I'm interested to know about the status of the integration of the Sunlight Congressional data API. I haven't been able to find any recent news about it, or any official documentation of how to setup on the wiki, or visible signs of it in the online demo.   

It seems like a great feature!

   Mark

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Status of Sunlight Congressional Data integration in CiviCRM 2?
March 07, 2008, 10:14:43 am

We did some proof of concept integration with it and see if anyone in the community would be interested. Your post has been the first response we've gotten on it (since release, past 8 months or so?). Its a bit surprising but the community has not shown much/any interest in sunlight / citizen speak / direct advocacy type tools. There has been a fair amount of interest in a generic "Petition" component.

We did not go beyond the proof of concept due to lack of interest. At this stage it does not make a lot of sense for us to push it forward internally. You should be able to resurrect the code and move it along if interested :) Contact us on IRC and we can point you in the right direction.

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jsimonis

  • I post frequently
  • ***
  • Posts: 316
  • Karma: 4
    • Forward Support, Inc.
  • CiviCRM version: 4.4-4.5
  • CMS version: Drupal 7
  • MySQL version: 5.5.37-cll
  • PHP version: 5.3.29
Re: Status of Sunlight Congressional Data integration in CiviCRM 2?
April 27, 2008, 12:05:37 am
I don't recall seeing anything on this before, but then I'm not on the site all the time.

I'd love to see something like this. I know a lot of groups that want something like this and have been trying to find an open source solution. For many of them, having a solution like this would be the difference between using Drupal/CiviCRM and going elsewhere.

We're actually about to hold a Drupal training event here in Portland, and one of the tracks is on using Drupal for community groups, non-profits, etc. And to me, CiviCRM is always a big part of that. Having the ability to do something like CitizenSpeak where you could put in your address info and be able to pull up your elected official(s) and then contact them on a targeted issue would be a huge step forward for using Drupal and CiviCRM for these organizations.

acrosman

  • Guest
Re: Status of Sunlight Congressional Data integration in CiviCRM 2?
April 27, 2008, 03:01:26 pm
During the CiviCRM bootcamp back in March, I worked with some of the folks over at DharmaTech to develop this functionality. We'd run into some significant speed problems that they were planning on following up on.  I don't know where it got left after that.

Aaron

dharmatech

  • I post frequently
  • ***
  • Posts: 280
  • Karma: 53
    • dharmatech.org
Re: Status of Sunlight Congressional Data integration in CiviCRM 2?
April 29, 2008, 11:14:38 am
Hi Mark,

With the help of Aaron and Greenberg, we did in fact get the Sunlight stuff working.  We also corrected the way in which it was pulling down representatives.  In talking with the Sunlight folks at NTEN they indicated the API is in flux but was expected to solidify within the next couple of months.

The big problem we saw was performance... sometimes fast, sometimes slow.  To use this for more than just proof-of-concept, you would probably want to implement some type of caching mechanism.  At least that's what we talked about doing if we wanted to roll this out to our groups.

The patch for CiviCRM 2.0.0 is attached.  Obviously you should apply this against a test copy of CiviCRM, not production.  You will need to make sure define('CIVICRM_SUNLIGHT',1); is in your civicrm.settings.php.  Once enabled, you get an "Elected Officials" tab for a Contact.

Jason

http://dharmatech.org
oss@dharmatech.org
801.541.8671

dharmatech

  • I post frequently
  • ***
  • Posts: 280
  • Karma: 53
    • dharmatech.org
Re: Status of Sunlight Congressional Data integration in CiviCRM 2?
April 30, 2008, 08:57:22 am
For those of you not interested in logging in to view attachments...

Index: CRM/Contact/Page/View/Sunlight.php
===================================================================
--- CRM/Contact/Page/View/Sunlight.php   (revision 85)
+++ CRM/Contact/Page/View/Sunlight.php   (working copy)
@@ -44,15 +44,16 @@
      * @access public
      */
     function browse( ) {
-        // get the primary city, state and zip for the contact
         require_once 'CRM/Contact/BAO/Contact.php';
         $ids = array( $this->_contactId );
         $locations = CRM_Contact_BAO_Contact::getMapInfo( $ids );
-       
+
         require_once 'CRM/Utils/Sunlight.php';
-        $rows =& CRM_Utils_Sunlight::getInfo( $locations[0]['city'],
-                                              $locations[0]['state'],
-                                              $locations[0]['postal_code'] );
+
+        $rows =& CRM_Utils_Sunlight::getInfo( $locations[0]['lat'],
+                                              $locations[0]['lng'],
+                                              $locations[0]['state'] );
+
         $this->assign( 'rowCount', count( $rows ) );
         $this->assign_by_ref( 'rows', $rows );
     }
@@ -66,12 +67,9 @@
      */
     function run( ) {
         $this->preProcess( );
-
         $this->browse( );
-
         return parent::run( );
     }
-
 }
 
 ?>
Index: CRM/Utils/Sunlight.php
===================================================================
--- CRM/Utils/Sunlight.php   (revision 85)
+++ CRM/Utils/Sunlight.php   (working copy)
@@ -47,6 +47,12 @@
         if ( PEAR::isError( $result ) ) {
             CRM_Core_Error::fatal( $result->getMessage( ) );
         }
+
+/*
+        echo "Start: $uri: " . time( ) . "<p>";         
+        flush( );
+*/
+
         if ( $request->getResponseCode( ) != 200 ) {
             CRM_Core_Error::fatal( ts( 'Invalid response code received from Sunlight servers: %1',
                                        array(1 => $request->getResponseCode())) );
@@ -94,25 +100,45 @@
 
     static function getPeopleInfo( $uri ) {
         $xml = self::makeAPICall( $uri );
+        /*
+        CRM_Core_Error::debug("getPeopleInfo()", $xml);
+        exit();
+        */
         
-        $result = array( );
-        foreach ( $xml->entity_id_list->entity_id as $key => $value ) {
-            $result[] = self::getDetailedInfo( $value );
+        if (isset($xml->entity_id_list)){
+            $result = array( );
+            foreach ( $xml->entity_id_list->entity_id as $key => $value ) {
+                $result[] = self::getDetailedInfo( $value );
+            }
         }
+        else {
+            $result = array( );
+            $result[] = self::getDetailedInfo( $xml->entity_id );
+        }
         return $result;
     }
 
-    static function getRepresentativeInfo( $city, $state ) {
-        if ( ! $city ||
-             ! $state ) {
-            return null;
-        }
+    static function getRepresentativeInfo( $lat, $long, $state ) {
         $key  = self::$_apiKey;
         $city = urlencode( $city );
-        $uri  = "people.reps.getRepsFromCityState.php?city={$city}&state={$state}&apikey={$key}&output=xml";
+        $district = self::getDistrictByLatLong($lat, $long);
+
+        $uri  = "people.reps.getRepFromDistrict.php?state={$state}&district={$district}&output=xml";
         return self::getPeopleInfo( $uri );
     }
 
+
+    static function getDistrictByLatLong( $lat, $long ) {
+        $key  = self::$_apiKey;
+        $uri  = "places.getDistrictFromLatLong?latitude={$lat}&longitude={$long}&output=xml";
+        $xml = self::makeAPICall( $uri );       
+        $district = $xml->districts->district;
+
+        // ugh, converts "01" to "1"
+        return $district+0;
+    }
+
+
     static function getSenatorInfo( $state ) {
         if ( ! $state ) {
             return null;
@@ -123,12 +149,8 @@
         return self::getPeopleInfo( $uri );
     }
 
-    static function getInfo( $city, $state, $zipcode = null ) {
-        if ( $zipcode ) {
-            list( $city, $state ) = self::getCityState( $zipcode );
-        }
-
-        $reps = self::getRepresentativeInfo( $city, $state );
+    static function getInfo( $lat, $long, $state ) {
+        $reps = self::getRepresentativeInfo( $lat, $long, $state );
         $sens = self::getSenatorInfo( $state );
 
         $result = array( );

http://dharmatech.org
oss@dharmatech.org
801.541.8671

dharmatech

  • I post frequently
  • ***
  • Posts: 280
  • Karma: 53
    • dharmatech.org
Re: Status of Sunlight Congressional Data integration in CiviCRM 2?
May 14, 2008, 09:36:04 am
For anyone interested, I updated the diff to run under CiviCRM 2.0.3 w/the latest Sunlight API.  The API is still in flux so YMMV.  I'm attaching the diff and tarball of the code changes.  Just extract the tarball under modules/civicrm or apply the diff with patch.

http://dharmatech.org
oss@dharmatech.org
801.541.8671

pixelbricks

  • Guest
Re: Status of Sunlight Congressional Data integration in CiviCRM 2?
October 22, 2009, 05:49:03 pm
Was searching for citizenspeak functionality for civicrm and came across this post.  I feel like this would be a great addon for civicrm.  With the proliferation of online advocacy groups, this letter sending/petition signing function is a small gap in the civicrm toolset.

Sunlight Foundation is doing amazing work as is the civicrm team.  The big push right now with Health Care Reform, Net neutrality &  Climate legislation advocacy campaigns is tipping more people off to the importance and power of online advocacy.

I'd support re-opening this topic and potentially putting some financial resources together to build out the online petition/letter sending toolset.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Status of Sunlight Congressional Data integration in CiviCRM 2?
October 22, 2009, 05:50:54 pm
Quote from: pixelbricks on October 22, 2009, 05:49:03 pm
I'd support re-opening this topic and potentially putting some financial resources together to build out the online petition/letter sending toolset.

Would you be interested in taking the lead on this and start pulling the pieces together?

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

randallemery

  • Guest
Re: Status of Sunlight Congressional Data integration in CiviCRM 2?
October 26, 2009, 11:09:22 am
Please count me in to support this effort.  I'm on the board of a 501(c)(4) and this functionality would really benefit our organization.  I don't have the time to lead this, but I would support it any way I could.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Pre-installation Questions (Moderator: Dave Greenberg) »
  • Status of Sunlight Congressional Data integration in CiviCRM 2?

This forum was archived on 2017-11-26.