Created
November 27, 2012 23:22
-
-
Save white-gecko/4157904 to your computer and use it in GitHub Desktop.
Small script to test Semantic Pingback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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änger</th><td><input type="text" name="to"/> (hier kannst du die WebID des Empfä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