I know there are quite a few libraries out there that that allow Twitter to be integrated into a website. But I haven't yet found what I am looking for (or maybe my understanding of twitter API is lacking). I want to be able to tweet events that occur on my website - BUT in addition, I want to be able to add tweeted from www.example.
For instance, when I send tweets from my blackberry or iphone (or indeed from some other sites), underneath the tweet, there is a message that says, tweeted from (for example blackberry). Does anyone know of a PHP library or class that allows me to send tweets but also with a kind of 'signature' that says where the tweet was sent from?
Edit
Additionally, I want users to be able to tweet from my website. When they tweet, I would like the tweet to say that where it came from (for example, like it does for blackberry phones etc, as I described above).
It is not clear to me whether I still need a PHP application for this requirement, and also how to implement it. Do I need an additional library for allowing users to tweet from my website?
Note: my users do not log into my website using a twitter login, so my website does not have access to a users Twitter username/password etc.
First you must register an app at http://twitter.com/apps, then you can use this twitter class -> http://classes.verkoyen.eu/twitter_oauth
I wrote a tutorial on how to do this http://blog.cmstutorials.org/reviews/general/how-to-update-your-twitter-status-using-php , just follow the steps and you should be good to go
edit: how to include a link
you can write function to get a shortened url because you only have 140 charachters you can then use this function:
function getBitlyUrl($url)
{
$bitlylogin = 'your login name';
$bitlyapikey= 'your api key';
$bitlyurl = file_get_contents("http://api.bit.ly/shorten?version=2.0.1&longUrl=".$url."&login=".$bitlylogin."&apiKey=".$bitlyapikey);
$bitlycontent = json_decode($bitlyurl,true);
$bitlyerror = $bitlycontent["errorCode"];
if ($bitlyerror == 0) {
$bitlyurl = $bitlycontent["results"][$url]["shortUrl"];
}
else $bitlyurl = "error";
return $bitlyurl;
}
then just call it like this:
$url = getBitlyUrl('yourlink');
you can then just add $url
to your tweet
You need to create an application in twitter. And tweet via that application (using API) on twitter. the 'via XYZ' will be automatically added.
http://www.twitter.com/apps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With