CKEditor – Get Content


<textarea id=”content_id”></textarea>

<input type=”button” value=”Clickme” onclick=”showData()” />

<script type=”text/javascript”>

function showData(){

var sourceText = CKEDITOR.instances[“content_id”].getData();

alert(sourceText);

}

</script>

PHP – Accessing Google Translate with CURL


save the script below to gtproxy.php

change the langpair query string value to your desired value, here I use id (indonesian) to en (english)

langpair=id%7Cen

then test using content as query string to store text which will be translated

eg: gtproxy.php?content=percobaan

<?php

function replace_unicode_escape_sequence($match) {
return mb_convert_encoding(pack(‘H*’, $match[1]), ‘UTF-8’, ‘UCS-2BE’);
}

$query  = trim($_GET[‘content’]);
$query  = urlencode($query);

$ch     = curl_init();
curl_setopt($ch, CURLOPT_URL, “http://www.google.com/uds/Gtranslate?callback=google.language.callbacks.id100&langpair=id%7Cen&key=notsupplied&v=1.0&context=22&q=$query&#8221;);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$contents = curl_exec ($ch);

curl_close ($ch);

$str = preg_replace_callback(‘/\\\\u([0-9a-f]{4})/i’, ‘replace_unicode_escape_sequence’, $contents);

echo substr($str, 57, -19);

?>

Facebook – Specify Article Picture When Visitor Click Like Button


<meta property="og:title" content="This is my title" />
<meta property="og:type" content="activity" />
<meta property="og:url" content="http://www.mysite.com/redirect/" />
<meta property="og:image" content="http://www.mysite.com/logo.jpg" />
<meta property="og:site_name" content="I'm on Facebook!" />
<meta property="og:description" content="Hello World!" />

use: <meta property="og:image" content="http://www.mysite.com/logo.jpg" />

PHP – Get Youtube Video Title (based on supplied Video ID)


<?php
$video_id = ’48J_DIZBNyE’;
$content = file_get_contents(“http://youtube.com/get_video_info?video_id=&#8221; . $video_id);
parse_str($content, $ytarr);
echo $ytarr[‘title’] . ‘<hr>’ ; // title
?>
 
update:
you can also use this way
<?php
$video_id = ’48J_DIZBNyE’;
$video_info = simplexml_load_file(‘http://gdata.youtube.com/feeds/api/videos/&#8217;.$video_id.’?v=1′);
echo $video_info->title . ‘<hr>’; // title
echo $video_info->content; // description
?>