A PHP library for use with the Vote Smart API.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



A PHP library for use with the Vote Smart API(http://votesmart.org/share/api).


The PHP libraries require PHP 5 with the SimpleXML extension and allow_url_fopen set to On in php.ini.


Using the libraries is fairly simple. You initialize the object with the name one of the methods and any arguments needed in an array. Then a call go getXmlObj() can be made to retrieve a SimpleXML object to work with. Let's say you wanted to get information on a bill...:

// Initialize the VoteSmart object
$obj = new VoteSmart(
                'candidateId' => 9026

// Get the SimpleXML object
$x = $obj->getXmlObj();

Now $xml_object is a SimpleXML object representative of the XML structure. Here's a small cut from the XML itself.:

<?xml version="1.0" encoding="UTF-8"?>
                <title>Project Vote Smart - Bio - Rep. Stephen Scalise</title>



Let's say you wanted to get the candidateId of the candidate. You could simply access it like this:

echo $x->candidate->candidateId;

And anything with repeating rows like say, committee memberships would just be treated as an array:

echo $x->office->committee[0]->committeeName;

Documentation and Support

All documentation on our API can be found at http://api.votesmart.org/docs/

Any questions about the API or this library can be sent to webmaster@votesmart.org.