// get signatures for a Change.org petition
function getChangePetitionSignatureCount($url){
$CHANGE_API_KEY = 'API_KEY';
$CHANGE_REQUEST_URL = 'https://api.change.org/v1/petitions/get_id';
$parameters = array(
'api_key' => $CHANGE_API_KEY,
'petition_url' => $url
);
$query_string = http_build_query($parameters);
$final_request_url = "$CHANGE_REQUEST_URL?$query_string";
$response = file_get_contents($final_request_url);
$json_response = json_decode($response, true);
$petition_id = $json_response['petition_id'];
//now get the petition details for signature count
$CHANGE_REQUEST_URL = 'https://api.change.org/v1/petitions';
$parameters = array(
'api_key' => $CHANGE_API_KEY,
'petition_ids' => $petition_id
);
$query_string = http_build_query($parameters);
$final_request_url = "$CHANGE_REQUEST_URL?$query_string";
$response = file_get_contents($final_request_url);
$json_response = json_decode($response, true);
$petition = $json_response['petitions'][0];
$sig_count = $petition['signature_count'];
//var_dump($json_response);
return $sig_count;
}