Posts Tagged: code example


8
Sep 11

How to read pages with PHP and Diffbot, a visually learning robot

Say you want to copy Facebook’s any-page-on-the-web sharing feature where a title, photo and part of the content is automagically presented to the user. Or you want to build yet another news reading service (after you finished building your geo-location group-chat app ;) ). You can now do this with Diffbot. Continue reading →


29
Jul 11

Fixing UTF encoding in AJAX requests on Internet Explorer

The legendary status of Internet Explorer for being special among all browsers was reminded to me when I discovered that sending a variable with non-latin character in a GET request over AJAX is apparently too troubling for IE. The result is that characters in greek are either transformed to latin ones or just disappear. This was all in a simple call like this:

$("#search_result").load("/ajaxsearch/&id=$id&f="+what);

(Where [i]what[/i] was the value of an input used in a AJAX-powered “quick search” form. Calling the same URL on a normal (non-AJAX) request everything worked perfectly.
The solution (after trying for hours to figure out what kind of transformation IE was doing on the value of the string), was simple enough: send it via POST

$.post("/ajaxsearch/&id=$id&",{ f: what },
 function(returned_data) {
   $("#search_result").html(returned_data);
 });

I guess since it was a input box, I should have treated the call as a form and used POST from the start, right?


9
Jul 11

Adding OG Tags in WordPress


I’ve been using the FB Connect plugin for allowing visitors to login on the blog. It adds the Open Graph tags that Facebook reads to determine how a page will be displayed on a Facebook stream when shared, but not all of them. The description and image tags are missing, plus there are not tags on the home page, only the posts. I’ve set out to change this. Continue reading →