Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of sending Bridgy Publish webmention
<?php namespace ProcessWire;
* This is an example of how I use Bridgy Publish.
* This is for reference only, not necessarily the cleanest/best way to do this. :)
* 1. When an admin views a note that isn't already syndicated to Twitter, display a Bridgy Publish button (not included in this file)
* 2. When that form is submitted, use the module to send a Webmention to Bridgy Publish
* 3. Decode and parse the JSON for the Twitter URL
* Note: my template has textarea field `syndication` for syndication URLs. I put the Bridgy Publish Twitter URL there and replace it with the tweet permalink after successful publishing.
if ($input->post->tweet_this) {
$is_success = false;
$Webmention = $modules->get('Webmention');
$response = $Webmention->sendWebmention($page->httpUrl, '');
# attempt to decode the JSON response from
$json = json_decode($response);
# JSON decoded
if (!is_null($json)) {
# Tweet URL found
if (!empty($json->url)) {
$page->syndication = trim(str_replace('', $json->url, $page->syndication));
$is_success = true;
if (!$is_success) {
echo 'Published successfully!';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment