maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Off Topic (https://talk.maemo.org/forumdisplay.php?f=19)
-   -   Beaker: twitter web service project proposal (https://talk.maemo.org/showthread.php?t=37458)

Texrat 2009-12-16 21:34

Beaker: twitter web service project proposal
 
I've decided to learn Python, Qt, and related technologies because they make the most sense for where I am going.

I want to start with a web service since I will need to get up to speed on wsdl, etc, fairly quickly for work. (EDIT: see note below)

I'll sketch out my idea here first because I want to capture thoughts in a place I almost live (:D) but second because I want to expose the idea in case others are interested in participating.

The basic idea of Beaker is a twitter web service that could be integrated into discussion pages. The program would capture lengthy post content, partition it into 2 or more twitter-length chunks that include key metadata and then submit the tweets.

Chunks would be prefixed by "x/y" whereas "x" is the number of the chunk from first to last, and "y" is the total number of chunks. Chunks would be suffixed by a bit.ly url pointing back to the original comment, article, etc.

I'm fairly adept at building logical parsing engines in general so I can model this easily-- but I'm very new to Python and related tools so it will take me a while to get going on implementation. Again, I am not opposed to anyone stepping in for that BUT in a transparent way that will help me (and others) learn.

Later I will write up some pseudo code to get the modeling underway.

EDIT: it occurred to me it makes more sense to do this in javascript I think...

hypnotik 2009-12-16 21:42

Re: Beaker: twitter web service project proposal
 
You might want to consider a RESTful API for webservices instead of going with a full blown SOAP/WSDL interface - will make things more lightweight.

Texrat 2009-12-16 21:47

Re: Beaker: twitter web service project proposal
 
I'll look into that, thanks!

Texrat 2009-12-16 22:18

Re: Beaker: twitter web service project proposal
 
Pseudocode:

Code:

Chunk count = 0 //x
Chunk total = 0 //y
Capture text content of comment form
  Trigger POST method of comment form
    Capture page url after update
    Create short url of page url via bit.ly
    Save length of bit.ly url in numeric variable
    authenticate user in twitter
      While not end of comment text
        chunk count = chunk count + 1
          parse comment text until chunk is built:
            chunk max length = 140 - ((bit.ly url + 1) + len("x/y") + 1)
            // x = chunk number
            // y = chunk total
          // chunk needs to take spaces into account--
          // break chunks on spaces, never any other character
          // this means chunks will often be less than 140 characters
          chunk = x/y + " " + tempchunk + " " +bit.ly.url
        end parse
        chunk total = chunk total + 1
        delete chunk text from overall comment
        submit chunk as tweet
      end while
 
cleanup/close

let me know if I missed anything! This is pretty rough

Texrat 2009-12-23 20:23

Re: Beaker: twitter web service project proposal
 
I could sure use some help on this.

I have almost zero experience with web service development, so I'm not really sure where to start other than the pseudocode I posted above. I only know that I want this to work like other utilities, such as those for facebook, twitter, et al, that can be hosted on a web page and Just Work.

Ideas?

EIPI 2010-02-08 01:59

Re: Beaker: twitter web service project proposal
 
Texrat - I started a python/qt application from scratch less than 2 weeks ago. That included installing a full ubuntu partition on my laptop, the maemo sdk, learning python, qt and integrating with a webservice. My app works - just packaging problems (lots) that I am struggling with.

The webservice I used was based upon SOAP, and that was very easy to do with some googling and using the python-suds module. Let me know if you need some help - I may be able to muddle my way through. Cheers!

Texrat 2010-02-08 02:44

Re: Beaker: twitter web service project proposal
 
I just saw your packaging post-- hope someone can figure it out!

With this project I mainly wanted to create a web service app/plugin/whatever, but I'm also going to get it to run on the N900 if I can. Maybe the witter developer or others could find a use for the result.

EIPI 2010-02-08 02:50

Re: Beaker: twitter web service project proposal
 
Ahhh - I missed that - mea culpa. In any case, the offer (as little as it may be), still stands

RevdKathy 2010-02-08 07:54

Re: Beaker: twitter web service project proposal
 
I think I understood the word 'twitter'.

When you have time, a quick explanation of what this will do and why I might want it in words comprehensible to a bear of very little brain would be gratefully received.

I'm a user of twitter (among other things, I try to greet every single person who announces a new #n900!) so anything to make twitter easier is good for me. I currrently use Witter, and am very grateful to Daniel for it. :)

Texrat 2010-02-08 07:56

Re: Beaker: twitter web service project proposal
 
The idea is a utility that will break big posts into serialized twitter messages.

RevdKathy 2010-02-08 08:00

Re: Beaker: twitter web service project proposal
 
Ahhh gotcha. :)

robbie 2010-02-08 10:16

Re: Beaker: twitter web service project proposal
 
Quote:

Originally Posted by Texrat (Post 515643)
The idea is a utility that will break big posts into serialized twitter messages.

Wouldn't that defeat the 'purpose' of twitter?

Texrat 2010-02-08 16:46

Re: Beaker: twitter web service project proposal
 
Quote:

Originally Posted by robbie (Post 515886)
Wouldn't that defeat the 'purpose' of twitter?

People are doing it anyway, manually. And I'm not talking about novels.

Texrat 2010-03-14 01:20

Re: Beaker: twitter web service project proposal
 
Heh... just got the VB.Net version of this code working. Bracing for backlash... :D

Texrat 2010-03-14 17:18

Re: Beaker: twitter web service project proposal
 
In case anyone is interested, here's the VB.Net version of the multi-tweet code:

Code:

        If Tweet_TextBox.Text.Length > 140 Then
            Do While tempTweet.Length >= 132
                chunkCut = 132
                While tempTweet.Substring(chunkCut, 1) <> " "
                    'test for punctuation too (?!,;)
                    chunkCut = chunkCut - 1
                End While
                tweetChunk(chunkCount) = tempTweet.Substring(0, chunkCut).Trim
                tempTweet = tempTweet.Remove(0, chunkCut)
                chunkCount = chunkCount + 1
            Loop
            tweetChunk(chunkCount) = tempTweet.Trim
            For tweets = 0 To chunkCount
                tweetUpdate = (tweets + 1).ToString & "/" & (chunkCount + 1).ToString & " " & tweetChunk(tweets)
                If tweets < chunkCount Then tweetUpdate = tweetUpdate & " +"
                tw.Update(tweetUpdate)
            Next
        Else
            tw.Update(Tweet_TextBox.Text)
        End If
        Tweet_TextBox.Clear()

Basically it looks to see if the tweet has more than 140 characters, and if so, breaks it down into serialized chunks. Because it can't predict the number of chunks accurately, I allow for prefixed serial part to be xx/yy so if it's x/y then the tweet "misses" 3 characters for total length (I add a space too). In addition, I add a space and + character at the end so that's 2 more. In other words, most tweets will be 135 characters or less.


All times are GMT. The time now is 08:09.

vBulletin® Version 3.8.8