Easy to use quimble php API function
function quimble_connect
($end_point,
$id = nil,
$xml = nil
) {
/*Begin generic configuration */
$host =
"http://quimble.com/api/";
$username =
"" //INSERT YOUR USERNAME;
$password =
"" //INSERT YOUR PASSWORD;
/*end generic configuration */
$request =
$host .
$end_point;
/* Combine the configured host and the passed in endpoint */
if($id) $request =
$request .
"/" .
$id;
$session = curl_init
();
curl_setopt
($session, CURLOPT_URL,
$request);
// set url to post to
curl_setopt
($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC
);
curl_setopt
($session,CURLOPT_USERPWD,
$username .
":" .
$password);
curl_setopt
($session, CURLOPT_HEADER,
false);
curl_setopt
($session, CURLOPT_HTTPHEADER,
array('Accept: application/xml',
'Content-Type: application/xml'));
curl_setopt
($session, CURLOPT_RETURNTRANSFER,
true);
/*if $xml has been passed in - then we'll post it to Quimble */
if($xml) {
curl_setopt
($session, CURLOPT_POST,
1);
curl_setopt
($session, CURLOPT_POSTFIELDS,
$xml);
} /* end if($xml) */
curl_setopt
($session, CURLOPT_RETURNTRANSFER,
true);
$response = curl_exec
($session);
curl_close
($session);
return $response;
} /*end quimble_connect */
?>
Highly recommended: use php5 and simple XML to parse the response:
$poll = simplexml_load_string
(quimble_connect
("get",
$YOUR_POLL_ID));
?>
<h2><?
echo $poll->
question ?></h2>
<ul>
<?
foreach($poll->
options->
option as $option) {
echo "<li><a href='javascript:quimble_vote(" .
$option->
id .
")'>" .
$option->
name .
"</a></li>";
}
?>
</ul>
<p
class=
"quimble_powered_by"><a href=
"http://quimble.com">Powered by Quimble</a></p>
There are 637 comments on this page. [Display comments]