Hello again, long time since I’ve post my last blog.. 🙂
I’ve experienced when trying to integrate my website with other web services I already registered, such as WordPress, Facebook, Youtube. In this blog I’m only share my experience on how to feed WordPress content.
The main goal of my wishes are all contents i took on those services will shown on my website just like that shown on that services, just because I don’t want to build my website with CMS.
Basically, all contents available on those services are available to to retrieve. So, i began to write my php code, give cUrl functionality to retieve that. Gladly, wordpress give a mobile version while we open it on mobile device by default, then with curl_setoption function I set CURLOPT_USERAGENT to Opera mini.
After all string content retrieve, next step is create two DOMDocument object. First document stored with all copied string content from cUrl. Then parsed to get only from element with id is singlentry. Second document object loaded with basic empty DIV element. Next step, the second document object need to be importing from the element parsed on the first document. Then just simply showing second document to the browser. Below are completed code writen.
$url = "http://your.wordpress.com/blog/post/entry";
$cs = curl_init($url);
curl_setopt($cs, CURLOPT_HTTPGET, 1);
curl_setopt($cs, CURLOPT_RETURNTRANSFER, 1);
"Opera/9.50 (J2ME/MIDP; Opera Mini/4.0.9800/209; U; en)");
$resp = curl_exec($cs);
$doc = new DOMDocument();
$blog = $doc->getElementById("singlentry");
$doc2 = new DOMDocument();
$node = $doc2->importNode($blog, true);
Wait………. just take a cigaratte and a cup of coffee and turn on Motorhead’s Ace of Spades with a loud (if you don’t have it, just open it on Youtube).
Now, my wordpress blog post can be shown on my website without specific API.