WinDev – Have some fun with Social Networks

tw Social Networks like Twitter are great fun when you are in the mood to create some little apps.

Here’s a simple example code to get some of my friends tweets. All I did was look through the Twitter API and picked out a simple REST method to get some XML back as a test.

Reading XML in WinDev is very simple using a few methods. I recommend you run the URL in a browser and return back some XML data you can then use to play with. That way you are not making lots of calls to the Twitter API (which is limited by design anyway).

sLine <span style="color: #0000ff">is</span> <span style="color: #0000ff">string</span>
iPos <span style="color: #0000ff">is</span> int
sUrl <span style="color: #0000ff">is</span> <span style="color: #0000ff">string</span> = <span style="color: #006080">&quot;http://www.twitter.com/statuses/friends/funcoder.xml&quot;</span>
ListDeleteAll(LIST_Results)
&#160;
<span style="color: #0000ff">IF</span> HTTPRequest(sUrl) <span style="color: #0000ff">THEN</span>
    sResult <span style="color: #0000ff">is</span> <span style="color: #0000ff">string</span> = HTTPGetResult()
    
    XMLDocument(<span style="color: #006080">&quot;XMLDoc&quot;</span>,sResult)
    
    XMLFind(<span style="color: #006080">&quot;XMLDoc&quot;</span>,<span style="color: #006080">&quot;user&quot;</span>,XMLChildItem)
    
    <span style="color: #0000ff">WHILE</span> XMLFound(<span style="color: #006080">&quot;XMLDoc&quot;</span>)
        <span style="color: #0000ff">IF</span> XMLFind(<span style="color: #006080">&quot;XMLDoc&quot;</span>,<span style="color: #006080">&quot;created_at&quot;</span>, XMLElement) <span style="color: #0000ff">THEN</span>
            sLine = XMLData(<span style="color: #006080">&quot;XMLDoc&quot;</span>)
            
            <span style="color: #0000ff">IF</span> XMLFind(<span style="color: #006080">&quot;XMLDoc&quot;</span>,<span style="color: #006080">&quot;text&quot;</span>,XMLElement) <span style="color: #0000ff">THEN</span>
                sLine += <span style="color: #006080">&quot; | &quot;</span> + XMLData(<span style="color: #006080">&quot;XMLDoc&quot;</span>)
                
                <span style="color: #0000ff">IF</span> sLine &lt;&gt; <span style="color: #006080">&quot;&quot;</span> <span style="color: #0000ff">THEN</span>
                    ListAdd(LIST_Results,sLine)
                <span style="color: #0000ff">END</span>
            <span style="color: #0000ff">END</span>
            
&#160;
        <span style="color: #0000ff">END</span>
        
&#160;
        
        XMLFind(<span style="color: #006080">&quot;XMLDoc&quot;</span>,<span style="color: #006080">&quot;user&quot;</span>,XMLContinue)
    <span style="color: #0000ff">END</span>
    XMLCancelSearch(<span style="color: #006080">&quot;XMLDoc&quot;</span>)
    XMLClose(<span style="color: #006080">&quot;XMLDoc&quot;</span>)
END

You can then move on to some further experiments and combine different social networks to create some unique mashups.

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright FUNCODER – DEVELOPER & TECHNOLOGY ENTHUSIAST 2017
Shale theme by Siteturner