- Description: A method to retrieve summary data about a candidate.
- Arguments: Requires unique member_id that represents the candidate ID (cid) as provided by OpenSecrets. The OpenSecrets API is documented here along with sources for some obscure data. Additionally, it takes an optional 4-digit calendar year for election cycle.
- Special Note: The OpenSecrets API is different from the Sunlight Labs API. Though they share some of the same functionality for the purposes of this library, it is important to set the proper API endpoint and secure an OpenSecrets API Key. Also, be aware of rate limits and develop accordingly.
1 2 3 4 5 6 7 8 | api_key = 'XXXXXXXXXXXX'; $os->request_url = 'http://www.opensecrets.org/api/'; $os->rate_limit = 200; echo '<pre>'; print_r( $os->candidateInfo( 'N00000019', '2008' ) ); echo '</pre>'; ?> |
Result:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | stdClass Object ( [@attributes] => stdClass Object ( [cand_name] => Clinton, Hillary [cid] => N00000019 [cycle] => 2008 [state] => NY [party] => D [chamber] => S [first_elected] => 2000 [next_election] => 2012 [total] => 50597582 [spent] => 45412116 [cash_on_hand] => 5364334 [debt] => 36305 [origin] => Center for Responsive Politics [source] => http://www.opensecrets.org/politicians/summary.php?cid=N00000019&cycle=2008 [last_updated] => 12/31/2008 ) ) |



