Results 1 to 8 of 8

Thread: Converting a php program to Qt

  1. #1
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Default Converting a php program to Qt

    I have written a program that contacts twitter API to get the 20 latest tweets. Here is the code.

    Qt Code:
    1. <html>
    2. <head><title>
    3. Twitter API
    4. </title></head>
    5. </html>
    6.  
    7. <?php
    8.  
    9. $login = "1"; //Add the Username:password for authenticated sessions
    10.  
    11. $tweets = "http://twitter.com/statuses/public_timeline.xml";
    12.  
    13. $tw = curl_init();
    14. curl_setopt($tw, CURLOPT_URL, $tweets);
    15. curl_setopt($tw, CURLOPT_USERPWD,$login);
    16. curl_setopt($tw, CURLOPT_RETURNTRANSFER, TRUE);
    17.  
    18. $twi = curl_exec($tw);
    19. $tweeters = new SimpleXMLElement($twi);
    20. $latesttweets = count($tweeters);
    21.  
    22. //echo the data
    23.  
    24. foreach ($tweeters->status as $twit1) {
    25.  
    26. echo "<div class='name'>",'<b>'.$twit1->user->name.'</b>',"</div>";
    27. echo "<div class='text'>".$twit1->text." <div class='description'>","</div></div></div>";
    28.  
    29. }
    30.  
    31. curl_close($tw);
    32.  
    33. ?>
    To copy to clipboard, switch view to plain text mode 

    Now i need to write the same thing in Qt. Contacting the twitter API. How can i accomplish it?

    thanks

  2. #2
    Join Date
    Mar 2008
    Location
    Houston, Texas, USA
    Posts
    277
    Thanks
    9
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Converting a php program to Qt

    Qt-4.7.3 | Gentoo ~amd64 | KDE-4.7
    Aki IRC Client for KDE4 | Qt Documentation

  3. #3
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Default Re: Converting a php program to Qt

    thanks for replying.

    So I need to create a QNetworkAccessManager. Can anyone shed some light on it?

    How can i incorporate a browser in my application, how to duplicate wamp and things like that.

    I more question.
    How can i download all the files that are needed to run this application?

    http://doc.trolltech.com/4.5/network-http.html

    I have copied all the files and used Qt Open source, but the compiler says errors and wont execute.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Converting a php program to Qt

    Use QNetworkAccessManager to send a http query.

    For a browser use QWebView. As for your other problems, give us more details.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    srohit24 (19th March 2009)

  6. #5
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Default Re: Converting a php program to Qt

    What my app must do is this.

    Access the twitter API using the public_times
    Request latest 20 tweets
    Display the tweets

    I am new to Qt.

    Qt Code:
    1. QWebView *view = new QWebView(parent);
    2. view->load(QUrl("http://qtsoftware.com/"));
    3. view->show();
    To copy to clipboard, switch view to plain text mode 

    How can i make this sample code for webview run?

    thanks

  7. #6
    Join Date
    Mar 2008
    Location
    Houston, Texas, USA
    Posts
    277
    Thanks
    9
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Converting a php program to Qt

    Starting reading these to help you get started with Qt
    http://doc.trolltech.com/4.5/tutorials.html
    Qt-4.7.3 | Gentoo ~amd64 | KDE-4.7
    Aki IRC Client for KDE4 | Qt Documentation

  8. #7
    Join Date
    Feb 2009
    Posts
    143
    Thanks
    8

    Default Re: Converting a php program to Qt

    Thanks for the links guys. I have built my own browser using Qt.

    Now my question is, what is equivalent to curl in Qt.So that i can contact the Twitter API's.

    I have shown you my code in php. I just need a Qt version if it. Is it possible to deal with API's using QT??

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Converting a php program to Qt

    You have already been given the answer. You have even written the class name yourself in this thread.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Eclipse Integration and program not starting
    By Cruz in forum Installation and Deployment
    Replies: 1
    Last Post: 16th January 2009, 22:32
  2. Replies: 19
    Last Post: 21st January 2008, 09:13
  3. Replies: 5
    Last Post: 29th October 2007, 22:49
  4. Version setting in QT Program
    By sabeesh in forum Qt Programming
    Replies: 4
    Last Post: 24th October 2007, 12:07
  5. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.