Skip to content

Instantly share code, notes, and snippets.

@white-gecko
Created November 27, 2012 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save white-gecko/4157904 to your computer and use it in GitHub Desktop.
Save white-gecko/4157904 to your computer and use it in GitHub Desktop.
Small script to test Semantic Pingback
<?php
if (isset($_POST['comment'])) {
$to = 'http://example.com/resource#b';
$comment = $_POST['comment'];
$pingbackService = 'http://example.com/pingservice';
if (isset($_POST['from']) && !empty($_POST['from'])) {
$source = $_POST['from'];
} else {
$source = 'http://example.com/from-resource#a';
}
$fields = array ('source' => $source,
'target' => $to,
'comment' => $comment
);
// Should really replace curl with an ajax call
//open connection to pingback service
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$pingbackService);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//execute post
$return = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
//close connection
curl_close($ch);
} else {
echo '
<html>
<body>
<form action="" method="post">
<h1>Send me a Pingback</h1>
<table>
<tr>
<th>Absender</th><td><input type="text" name="from"/> (hier kannst du deine WebID eingeben)</td>
</tr>
<tr>
<th>Empf&auml;nger</th><td><input type="text" name="to"/> (hier kannst du die WebID des Empf&auml;ngers eingeben)</td>
</tr>
<tr>
<th>Text</th><td><textarea name="comment"></textarea></td>
</tr>
</table>
<input type="submit"/>
</form>
</body>
</html>
';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment