Examples

Syndicating YouTube Videos

1) Syndicate the YouTube feed (e.g. http://gdata.youtube.com/feeds/base/videos?q=Music).
2) Put the following code into the “PHP Code <?php .. ?>” box:

// assign preferred width and height of youtube video
$width = 450;
$height = 375;
// make sure the feed has the <content> tag. If not, use <description>
if ($post ['post_content'] == '') {
	$post ['post_content'] = $post ['post_excerpt'];
}
// extract youtube clip id
preg_match ( "/www.youtube.com\/watch\?v=(.*?)[&|\"]/s", $post ['post_content'], $matches );
$clip_id = $matches [1];
// create youtube player code and insert the extracted clip id there
$video = "<iframe width=\"$width\" height=\"$height\" src=\"http://www.youtube.com/embed/$clip_id\" frameborder=\"0\" allowfullscreen></iframe>";
// extract the clip description
preg_match ( "/<span>(.*?)<\/span>/s", $post ['post_content'], $matches );
$post ['post_content'] = "<p>" . $video . "</p>\n<p>" . $matches [1] . "</p>\n";

3) Save the settings and pull the feed.

Yes it’s that easy ;)

Using Google Translate with CyberSEO

1) Syndicate the new feed.
2) Put the following code into the “PHP Code <?php .. ?>” box:

// Set source language, e.g. English
$s = 'en';
// Set destination language, e.g. German
$d = 'de';
if ($post['post_content'] == '') {
	$post['post_content'] = $post['post_excerpt'];
}
$ch = curl_init();
 
curl_setopt($ch, CURLOPT_URL, 'https://www.googleapis.com/language/translate/v2?key=INSERT-YOUR-KEY&amp;source=' . $s . '&amp;target=' . $d . '&amp;q=' . urlencode($post['post_content']));
curl_setopt($ch, CURLOPT_REFERER, 'http://www.yoursite.com/translate.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$json = json_decode(curl_exec($ch), true);
$post['post_content'] = $json['data']['translations']['translatedText'];
$post['post_excerpt'] = $post['post_content'];

3) Replace INSERT-YOUR-KEY with your Google API key.

4) Save the settings and pull the feed.

The code above has two variables: $s and $d. Use them to set source and destination language for your feed. For example, if you want to translate the Danish feed to Spanish, use the following values:

$s = ‘da’;
$d = ‘es’;

Now you can use the Google Translate to automatically translate the XML and RSS feeds with the CyberSEO autoblogging plugin.

Using Yahoo! Babel Fish with CyberSEO

1) Syndicate the new feed.
2) Put the following code into the “PHP Code <?php .. ?>” box:

// Set source language, e.g. English
$s = 'en';
// Set destination language, e.g.: German
$d = 'de';
if ($post ['post_content'] == '') {
	$post ['post_content'] = $post ['post_excerpt'];
}
$translated = cseo_file_get_contents ( 'http://babelfish.yahoo.com/translate_txt?ei=UTF-8&intl=1&trtext=' . urlencode ( $post ['post_content'] ) . '&lp=' . urlencode ( $s . '_' . $d ) . '&btnTrTxt=Translate' );
$post ['post_content'] = preg_replace ( '/(^.*?<div id="result"><div style="padding:0.6em;">)(.*?)(<\/div>.*?$)/s', "\\2", $translated );
$post ['post_excerpt'] = $post ['post_content'];

3) Save the settings and pull the feed.

The code above has two variables: $s and $d. Use them to set source and destination language for your feed. For example, if you want to translate the Dutch feed to French, use the following values:

$s = ‘nl’;
$d = ‘fr’;

Now you can use the Yahoo! Babel Fish to automatically translate the XML and RSS feeds with the CyberSEO autoblogging plugin.