Ezeewp – making wordress easy for you
contact us contact us contact us contact us contact us

"Developing WordPress themes, templates and WordPress plugins"

So much social media integration

Sunday 9th August 2009 by admin

0

COMMENTS

As web developers – with a little bit of web design – as mentioned before in this blog – we are seeing more and more use of social media/networks as a way to assist in internet marketing.  Currently all the 5 website we are developing for clients require some form of social network intergration and we are continually looking for ways (and easy ones) that allow this and allow site owners to easilly access these networks.

Most people will have seen links like “Tweet this article now” where the link takes the visitor to Twitter, allows them to log in and post a tweet with a shortened URL – a bit like this URL http://tinyurl.com/mehaf4 or http://tinyurl.com/nnzqy2. If you have a basic knowledge of HTML and  PHP then there is a simple function that allows you to create this:

<?php
function create_tiny_url($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,‘http://tinyurl.com/api-create.php?url=’.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>

This PHP function uses CURL to access tinyurl and convert the variable $url to a tinyurl such as the ons above.

To call (use) this function on a page requires this code:

<?php

$new_url = create_tiny_url($_SERVER['PHP_SELF']);

echo ‘<a href=”http://twitter.com/home?status=Reading Your Site Name.$row ['a row from your query'].‘ ‘.$new_url.‘” title=”Put a title in here”> Tweet this item</a>’;

?>

Hope this helps people.

Popularity: unranked [?]

Please leave a response and trackback from your own site.

Leave a Reply