Subject: Can geeklog update my Twitter?

Posted on: 12/03/09 07:46pm
By: Anonymous

Hey
Can it?

Re: Can geeklog update my Twitter?

Posted on: 13/03/09 05:24am
By: Dirk

I'm afraid not, although it would probably make for a cute plugin ...

bye, Dirk

Re: Can geeklog update my Twitter?

Posted on: 13/03/09 08:09am
By: Anonymous

Sure would!...( hoping now some Plugin Developers see this thread ) :wink:

Re: Can geeklog update my Twitter?

Posted on: 13/03/09 02:52pm
By: Anonymous

Those developers wait for you to see the bounties' page (not wink).

Re: Can geeklog update my Twitter?

Posted on: 19/03/09 06:17am
By: Chase

there is a service which does that. i am forgetting its name.

It takes your RSS and posts it on your twitter.

ok here it is http://twitterfeed.com/

Re: Can geeklog update my Twitter?

Posted on: 03/07/09 09:23am
By: worldfooty


... except twitterfeed doesn't work with Geeklog RSS. It complains:

Please make sure your feed contains valid pubDate entries

It would also accept GUID.

Pretty much a showstopper as far as I can see. No idea whether it's easy to fix?



Re: Can geeklog update my Twitter?

Posted on: 03/07/09 09:40am
By: Dirk

Quote by: worldfooty

No idea whether it's easy to fix?


Easy enough: Make sure you're using a RSS 2.0 feed.

bye, Dirk

Re: Can geeklog update my Twitter?

Posted on: 04/07/09 12:29pm
By: ::Ben

Yes we can.

Create a first static page for your eyes only call sendTwitterMsg (ID) and change username and password in code

PHP Formatted Code

function postToTwitter($username,$password,$message){

    $host = "http://twitter.com/statuses/update.xml?status=".urlencode(stripslashes(urldecode($message)));

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $host);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
    curl_setopt($ch, CURLOPT_POST, 1);

    $result = curl_exec($ch);
    // Look at the returned header
    $resultArray = curl_getinfo($ch);

    curl_close($ch);

    if($resultArray['http_code'] == "200"){
         $twitter_status='Your message has been sended! <a href="http://twitter.com/'.$username.'">See your profile</a>';
    } else {
         $twitter_status="Error posting to Twitter. Retry";
    }
        return $twitter_status;
}

/* ---------------------------------------- */
// Change these parameters with your Twitter
// user name and Twitter password.
/* ---------------------------------------- */
$twitter_username ='username';
$twitter_psw ='password';
/* ---------------------------------------- */

/* Don't change the code belove
/* ---------------------------------------- */


if(isset($_POST['twitter_msg'])){
$twitter_message=$_POST['twitter_msg'];
if(strlen($twitter_message)<1){ $error=1; } else { $twitter_status=postToTwitter($twitter_username, $twitter_psw, $twitter_message); } }
/* ---------------------------------------- */

 


Then create a second static page still for your eyes only with this code and change url to point at your first page

PHP Formatted Code

echo '<h2>Post a message on Twitter</h2>';

if(isset($_POST['twitter_msg']) && !isset($error)){
echo '<div class="msg"><?php echo $twitter_status ?></div>';
} else if(isset($error)){
echo '<div class="msg">Error: please insert a message!</div>';
 }
echo '<p><strong>What are you doing?</strong></p>' .
'<form action="url_to_my_insertTwitterMsg_page" method="post">' .
'<input name="twitter_msg" type="text" id="twitter_msg" size="40" maxlength="140" />' .
'<input type="submit" name="button" id="button" value="post" />' .
'</form>';


and now tell the world what you are doing now from this second page.

::Ben

Re: Can geeklog update my Twitter?

Posted on: 04/07/09 03:00pm
By: LWC

Hopefully someone would take the aforementioned Twitter API for a plugin that uses functions PLG_itemSaved & PLG_itemDeleted (e.g. function plugin_itemsaved_twitter & plugin_itemdeleted_twitter). That way there'll be neither a need for a middleman site nor relying on RSS feeds. The plugin would be similar to XMLSitemap.

Re: Can geeklog update my Twitter?

Posted on: 05/07/09 05:59am
By: Anonymous

This is great! very cool.
I´m getting an error. When Click the post, I get this: http://www.mysite.no/url_to_my_insertTwitterMsg_page . Am I missing something?

Re: Can geeklog update my Twitter?

Posted on: 05/07/09 07:08am
By: Anonymous

Quote by: ITDiver

This is great! very cool.
I´m getting an error. When Click the post, I get this: http://www.mysite.no/url_to_my_insertTwitterMsg_page . Am I missing something?



My bad...I found what I was doing wrong, not pointing to my first page. Now I get this error.
atal error: Call to undefined function curl_init() in D:\Sitepath\plugins\staticpages\functions.inc(1189) : eval()'d code on line 5
Error in my_thread_global_end(): 2 threads didn't exit

Re: Can geeklog update my Twitter?

Posted on: 05/07/09 07:49am
By: Anonymous

The only thing different I´m doing is that I had to call the first static page for sendTwitterMsg_no (ID). Could this be the issue?

Thanks for any help here.

Re: Can geeklog update my Twitter?

Posted on: 05/07/09 08:00am
By: ::Ben

You need cURL

In order to use PHP's cURL functions you need to install the » libcurl package. PHP requires that you use libcurl 7.0.2-beta or higher. In PHP 4.2.3, you will need libcurl version 7.9.0 or higher. From PHP 4.3.0, you will need a libcurl version that's 7.9.8 or higher. PHP 5.0.0 requires a libcurl version 7.10.5 or greater.


::Ben

Re: Can geeklog update my Twitter?

Posted on: 05/07/09 08:49am
By: worldfooty


Thanks Ben, looks good.

But since I've already set up with Twitterfeed, I guess I'll just use that for now. I didn't realise the RSS version I was using was so old and that I just had to go into the options on Content Syndication and change it to RSS 2.0.

I then just had to be patient for Twitterfeed and Twitter to re-check and refresh.


Re: Can geeklog update my Twitter?

Posted on: 05/07/09 09:05am
By: ::Ben

Oops! I realise ITDiver maybe need to post automaticaly stories to twitter, so my code is not usefull in this case.

::Ben

Re: Can geeklog update my Twitter?

Posted on: 05/07/09 09:35am
By: Anonymous

You're supposed to use OAuth and not actual password.

Re: Can geeklog update my Twitter?

Posted on: 05/07/09 09:53am
By: Anonymous

Quote by: cordiste

Oops! I realise ITDiver maybe need to post automaticaly stories to twitter, so my code is not usefull in this case.

::Ben



Well..I really like this as well. I helps just to do all from one place so the code is very usefull to me. Just have to get the cURL to work. :-)

Thanks

Re: Can geeklog update my Twitter?

Posted on: 05/07/09 09:54am
By: Anonymous

Quote by: Guest

You're supposed to use OAuth and not actual password.



What do you mean by this????


Re: Can geeklog update my Twitter?

Posted on: 05/07/09 01:42pm
By: Anonymous

I meant the aforementioned API code that included a password. Twitter's API includes something called OAuth to prevent having to include a password in one's code. That's why twitterfeed, for example, doesn't need to know your password anymore.

Actualy, Twitter plans to eventually simply disable codes that use passwords. Read their OAuth FAQ.

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=86666