I’m really a big fan of oEmbed. My project Daily Fratze acts as oEmbed provider and consumer for example.
Now I’m really happy that twitter announced that it now acts as an oembed provider:
(I’d even be happier if twitter would autodiscover providers
)
To use this in a Java based application you can use my java-oembed lib with the following configuration:
Oembed oembed = new OembedBuilder(this.httpClient)
.withCacheManager(cacheManager)
.withBaseUri("http://yourproject")
.withConsumer("yourproject")
.withProviders(
new OembedProviderBuilder()
.withName("twitter")
.withFormat("json")
.withMaxWidth(480)
.withEndpoint("https://api.twitter.com/1/statuses/oembed.%{format}")
.withUrlSchemes("https?://twitter.com/#!/[a-z0-9_]{1,20}/status/\\d+")
.build()
)
.withHandlers(new CommonHandler("twitter"))
.build();
The handler looks like this:
import org.apache.commons.lang.StringEscapeUtils;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import ac.simons.oembed.OembedResponse;
import ac.simons.oembed.OembedResponseHandler;
public class CommonHandler implements OembedResponseHandler {
private String handlerFor;
public CommonHandler(String handlerFor) {
this.handlerFor = handlerFor;
}
@Override
public String getFor() {
return handlerFor;
}
@Override
public void handle(Document document, Element a, OembedResponse response) {
final StringBuilder hlp = new StringBuilder();
final String title = StringEscapeUtils.escapeHtml(response.getTitle());
if(response.getType().equalsIgnoreCase("video") || response.getType().equalsIgnoreCase("rich")) {
hlp.append("<span style=\"display:block; text-align:center;\">");
hlp.append(response.getHtml());
hlp.append("</span>");
} else if(response.getType().equalsIgnoreCase("photo")) {
hlp.append("<span style=\"display:block; text-align:center;\">");
hlp.append(String.format("<img src=\"%s\" alt=\"%s\" title=\"%s\" style=\"width: %d; height: %d;\" />", response.getUrl(), title, title, response.getWidth(), response.getHeight()));
hlp.append("</span>");
}
a.before(hlp.toString());
a.remove();
}
}
Be careful to get the latest release, twitter has some real large values for cache ages and i needed to update a member from int to long.
To have WordPress automatically embed statusupdates, add the following line to the “functions.php” of your current theme. Create the file if it isn’t available in the root folder of your theme:
wp_oembed_add_provider('#https?://twitter.com/\#!/[a-z0-9_]{1,20}/status/\d+#i', 'https://api.twitter.com/1/statuses/oembed.json', true);
Whenever you add the plain link (whithout an anchor tag) to a statusupdate on a single line in a post, it will be embedded like the example above.
Update
If you are more into plugins, just download my Enable Twitter oEmbed WordPress plugin, install it and you’re good to go.
An alternative to oEmbed for Twitter was the Twitter Blackbird Pie Plugin for WordPress, but why adding more stuff if everything else is already there? My plugin is much more lightweight.
Embedding me looks like this, by the way:

the picture will always show my latest update on daily fratze.
As this is probably the last post here for this year, i wish every visitor some nice christmas holidays!
Share This
The Extended Live Archives Plugin does not work with WordPress 3.0, opposed to the plugin page. I still like this plugin as seen here, so here is my solution:
- Download the archive
- Open includes/af-extended-live-archive.js.php and includes/af-ela.php in your favorite editor
- Replace in both files
require('../../../../wp-blog-header.php');
with
require_once('../../../../wp-config.php');
$wp_did_header = true;
$wp->init();
and you’re good to go.
If anyone has a better idea, please write a comment.
Share This
I use wp-cache on all my blogs all the time. No need waiting for being slashdotted or heised.
But wp-cache comes with a security flaw. It requires the webserver to have write access on $WP_HOME/wp-content/cache and $WP_HOME/wp-content. The first part is perfectly reasonable, the second not.
wp-cache creates it’s wp-cache-config.php in that place and edits this file consequently while being configured.
wp-cache comes with a sample config you can put in place. After that, chmod this file to 660 or something else that allows your webserver to edit it. Please don’t give your webserver write access to $WP_HOME/wp-content, especially not facing the current attacks on wordpress bloggers as described here.
I assume you know what your doing in the next step. All recommendations are tested and working with wp-cache 2.1.2. Open the file file wp-cache.php in your favorite editor, navigate to line 471 in function wp_cache_verify_config_file and change the following code
if ( !is_writable($dir)) {
echo "<b>Error:</b> wp-content directory (<b>$dir</b>) is not writable by the Web server.<br />Check its permissions.";
return false;
}
to
/*
if ( !is_writable($dir)) {
echo "<b>Error:</b> wp-content directory (<b>$dir</b>) is not writable by the Web server.<br />Check its permissions.";
return false;
}
*/
Alternatively, you can use the file i prepared: wp-cache.php. Rename it from *.php.txt to *.php and replace the old file with it.
Read more about the attack on wp blogs here. It’s shown that the attackers create a subfolder in your wp-contents. So it’s essential to chmod this folder to 0755 or even better to 0555 if you’re paranoid and only change it if you upload updates.
Share This
Am i the only one who’s annoyed that WordPress 2.5 sends a http 500 code if a commentor doesn’t fill in all required fields? Any Internet Explorer 6 or 7 user won’t see any error message but a “this page cannot be displayed!” page. Stupid decision.
Otherwise, the update went smooth as far as i can tell.
Edit: Oh dear… To me it seems that IE6 shows a browser default page everytime and IE7 sometimes displays the WP error page and sometimes not. If anyone can confirm this?
Edit 2: It’s silly. The Internet Explorer masks all 500 pages if their content is below a threshold of 512bytes with “User friendly messages”. User friendly your mom. The user can turn this off as described here but i don’t think that all IE users will do this just for the WP bloggers.
Summarizing it: It’s a plain stupid idea to use the http error 500 code for errors generated by user input as some users just cannot read them as the messages are not displayed to them.
Share This
As reported here and elsewhere, Dexter is somewhat talkative.
I recommend the following 2 steps program:
Stop sending your url
If you already have used WordPress 2.3, use the 123 Anonymer Versionscheck 0.10. It will anonymize your data, but a minimum of 1 request with personal data will happen, that is while using the plugin page.
If you do a fresh install of WordPress 2.3, i’d go with the my-hacks.php solution, because that way, no personal info will be send.
Lots of unnecessary Akismet informations
After finding the update problem this morning at Lumières dans la nuit, i read the following group. To my surprise i’ve learned, that the Akismet Spamchecker sends all of the $_SERVER environment variables from your server to the Akismet server. W T F?? I myself use Akismet in a custom project, there is absolutely no need to send this information. To stop sending this information, open akismet.php in your favorite editor, search and remove the following lines:
foreach ( $_SERVER as $key => $value )
if ( !in_array( $key, $ignore ) )
$comment["$key"] = $value;
Share This