Keyword

Tiny URL not working on 'Tweet this to your followers'

  • Lynn Heighton
  • Lynn Heighton's Avatar Topic Author
  • Offline
  • New Member
More
15 years 12 hours ago #73507 by Lynn Heighton
Hi,
I've created some pages on my site for latest news and job vacancies and have included the twitter social integration link for 'tweet this to your followers'
However, when I click this, it opens my link in Twitter but doesn't add a TINY URL.
I've checked in the K2 parameters and the option to show Tiny URL is checked.
If I uncheck this then the tweet shows the link, but it is too long.

Any ideas? Thanks in advance

Please Log in or Create an account to join the conversation.

More
14 years 11 months ago #73508 by pembaris
have you tried sign up with bit.ly and integrates with Twitter?

Last time I was using this for JReview, and I signed up Bit.ly, then I added my Twitter accounts on bit.ly page. I don't know if this will solve your problem, but maybe worth a try.

ps: k2 are becoming so popular, they are having shortage of workers. They never answer these days.

Please Log in or Create an account to join the conversation.

More
14 years 7 months ago #73509 by Ivan Descartes
Replied by Ivan Descartes on topic Tiny URL not working on 'Tweet this to your followers'
In my case, this was because the file_get_contents function in PHP is disabled by my host. This is a common hosting restriction, for security. I fixed this by replacing it with CURL function instead. To make the fix, find components/com_k2/views/item/view_html.php and replace:

if ($params->get('itemTwitterLink') && $params->get('twitterUsername')) {
$itemURLForTwitter = ($params->get('tinyURL')) ? @file_get_contents('tinyurl.com/api-create.php?url='.$item->absoluteURL) : $item->absoluteURL;
$item->twitterURL = 'twitter.com/home/?status='.urlencode('Reading @'.$params->get('twitterUsername').' '.$item->title.' '.$itemURLForTwitter);
}

With:

if ($params->get('itemTwitterLink') && $params->get('twitterUsername')) {

$itemURLForTwitter = $item->absoluteURL;

if($params->get('tinyURL')) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL,'tinyurl.com/api-create.php?url='.$item->absoluteURL);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$itemURLForTwitter = curl_exec($ch);
curl_close($ch);
}

$item->twitterURL = 'twitter.com/home/?status='.urlencode('Reading @'.$params->get('twitterUsername').' '.$item->title.' '.$itemURLForTwitter);
}

Please Log in or Create an account to join the conversation.

More
14 years 5 months ago #73510 by Simon Olsen
Before I start hacking my K2, has anyone else successfully done this? (No offense Ivan, I'm sure it works).

Ivan Descartes said:In my case, this was because the file_get_contents function in PHP is disabled by my host. This is a common hosting restriction, for security. I fixed this by replacing it with CURL function instead. To make the fix, find components/com_k2/views/item/view_html.php and replace...

Please Log in or Create an account to join the conversation.

  • Manolis Markatselas
  • Manolis Markatselas's Avatar
  • Offline
  • New Member
More
14 years 2 months ago #73511 by Manolis Markatselas
Replied by Manolis Markatselas on topic Tiny URL not working on 'Tweet this to your followers'
Excellent. This working fine.

Please Log in or Create an account to join the conversation.

  • Raymond Ringston
  • Raymond Ringston's Avatar
  • Offline
  • Junior Member
More
14 years 2 months ago #73512 by Raymond Ringston
Replied by Raymond Ringston on topic Tiny URL not working on 'Tweet this to your followers'
Worked perfectly. Thank you!

Please Log in or Create an account to join the conversation.

More
13 years 10 months ago #73513 by Omar Al-Ansari
Replied by Omar Al-Ansari on topic Tiny URL not working on 'Tweet this to your followers'
Works GREAT :D


Ivan Descartes said:In my case, this was because the file_get_contents function in PHP is disabled by my host. This is a common hosting restriction, for security. I fixed this by replacing it with CURL function instead. To make the fix, find components/com_k2/views/item/view_html.php and replace:
if ($params->get('itemTwitterLink') && $params->get('twitterUsername')) {
$itemURLForTwitter = ($params->get('tinyURL')) ? @file_get_contents('tinyurl.com/api-create.php?url='.$item->absoluteURL) : $item->absoluteURL;
$item->twitterURL = 'twitter.com/home/?status='.urlencode('Reading @'.$params->get('twitterUsername').' '.$item->title.' '.$itemURLForTwitter);
}

With:

if ($params->get('itemTwitterLink') && $params->get('twitterUsername')) {

$itemURLForTwitter = $item->absoluteURL;

if($params->get('tinyURL')) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL,'tinyurl.com/api-create.php?url='.$item->absoluteURL);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$itemURLForTwitter = curl_exec($ch);
curl_close($ch);
}

$item->twitterURL = 'twitter.com/home/?status='.urlencode('Reading @'.$params->get('twitterUsername').' '.$item->title.' '.$itemURLForTwitter);
}

Please Log in or Create an account to join the conversation.

More
13 years 10 months ago #73514 by depika k.
yes it works great !! Thanks for the tip !!

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #73515 by Matt Payne
Thanks this fixed it for me too!

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #73516 by Simon Olsen
Worked here too. Thank you.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum