Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QNetworkAccessManager && http example
Forum Updated to NodeBB v4.3 + New Features

QNetworkAccessManager && http example

Scheduled Pinned Locked Moved General and Desktop
16 Posts 8 Posters 15.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    luca
    wrote on last edited by
    #1

    Hi all,
    I'm trying to send sms from my application using an sms provider over internet (smsmobile.it) .

    They allow me to send sms by putting this string in a browser:

    http://sms.smsmobile-ba.com/sms/send.php?user=username&pass=password&rcpt=+39333XXXXXXX&data=message_text&sender=sender_name&qty=a

    And it works fine using firefox.

    Now I'm trying with the "http" example in qt 4.7 source (examples/network/http).

    It doesn't works but the problem is with the "rcpt" parameter. As you can see in the link I posted, there is a "+" (plus) character but I wrote the sequence "% 2 b" (without space).
    It seems like if the "% 2 b" sequence isn't recognized by QNetworkAccessManager in the url.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vinb
      wrote on last edited by
      #2

      Can't you compose a qstring first and then feed it to the browser?

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        This should do the trick:

        @
        QUrl url2("http://sms.smsmobile-ba.com/sms/send.php");
        url2.addQueryItem("user", "username");
        url2.addQueryItem("pass", "password");
        url2.addEncodedQueryItem("rcpt", QUrl::toPercentEncoding("+39333XXXXXXX"));
        url2.addQueryItem("data", "message_text");
        url2.addQueryItem("sender", "sender_name");
        url2.addQueryItem("y", "a");
        qDebug() << url2;
        qDebug() << url2.toEncoded();

        // QUrl( "http://sms.smsmobile-ba.com/sms/send.php?user=username&pass=password&rcpt=+39333XXXXXXX&data=message_text&sender=sender_name&y=a" )
        //"http://sms.smsmobile-ba.com/sms/send.php?user=username&pass=password&rcpt=+39333XXXXXXX&data=message_text&sender=sender_name&y=a"

        @

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • AlicemirrorA Offline
          AlicemirrorA Offline
          Alicemirror
          wrote on last edited by
          #4

          @Volker: You answered to a question I was though before I post the question :) Great!

          @Luca: If you are interested to a common share of the experience to manage a non-standard web application you can join also the "Naijanimi Free SMS":https://projects.forum.nokia.com/naijanimi project I'm setting up (take a look to the API specifications I am writing now on the project wiki).

          Enrico Miglino (aka Alicemirror)
          Balearic Dynamics
          Islas Baleares, Ibiza (Spain)
          www.balearicdynamics.com

          1 Reply Last reply
          0
          • L Offline
            L Offline
            luca
            wrote on last edited by
            #5

            [quote author="Volker" date="1299759052"]This should do the trick:

            @
            QUrl url2("http://sms.smsmobile-ba.com/sms/send.php");
            url2.addQueryItem("user", "username");
            url2.addQueryItem("pass", "password");
            url2.addEncodedQueryItem("rcpt", QUrl::toPercentEncoding("+39333XXXXXXX"));
            url2.addQueryItem("data", "message_text");
            url2.addQueryItem("sender", "sender_name");
            url2.addQueryItem("y", "a");
            qDebug() << url2;
            qDebug() << url2.toEncoded();

            // QUrl( "http://sms.smsmobile-ba.com/sms/send.php?user=username&pass=password&rcpt=+39333XXXXXXX&data=message_text&sender=sender_name&y=a" )
            //"http://sms.smsmobile-ba.com/sms/send.php?user=username&pass=password&rcpt=+39333XXXXXXX&data=message_text&sender=sender_name&y=a"

            @[/quote]

            It solved the problem!

            Thanks.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              swhweng
              wrote on last edited by
              #6

              Hello
              very interesting application feature
              So is it possible to add nessesary parameters to QUrl and send http request and the sms message sent to destination all over the world free of charge?
              Pavel
              15.03.2011

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dangelog
                wrote on last edited by
                #7

                Actually it's that server that sends short text messages.

                Parameters added to the url are the way of submitting HTML forms with GET method.

                http://www.w3.org/TR/html401/interact/forms.html#submit-format

                I'm 99.99% sure that that server must not use GET in this case, but let's not open a flame against PHP developers.

                Software Engineer
                KDAB (UK) Ltd., a KDAB Group company

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  swhweng
                  wrote on last edited by
                  #8

                  One moment please,
                  You should use QNetwrokAccessManager in new Qt codding tradition, shouldn't you?
                  It is not enought to use only QUrl - there is no methods to send to server anything?

                  bq. I’m 99.99% sure that that server must not use GET in this case, but let’s not open a flame against PHP developers.

                  Anything against any real developer for good.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    [quote author="Pavel Mazniker" date="1300201920"]You should use QNetwrokAccessManager in new Qt codding tradition, shouldn't you?[/quote]

                    Yes. And it has nothing to do with "coding tradition" (which I interpret as "coding conventions"). QUrl is a container for URLs only and is fed to QNetworkAccessManager.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      swhweng
                      wrote on last edited by
                      #10

                      bq. Yes. And it has nothing to do with “coding tradition” (which I interpret as “coding conventions”). QUrl is a container for URLs only and is fed to QNetworkAccessManager.

                      I mean some of developers advice to use the manager and not the QHttp after some new Qt version, that means tradition, but convention is will more than do.
                      So using one of QNetworkAccessManager methods you get your sms sent?

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on last edited by
                        #11

                        [quote author="Pavel Mazniker" date="1300205130"]bq. Yes. And it has nothing to do with “coding tradition” (which I interpret as “coding conventions”). QUrl is a container for URLs only and is fed to QNetworkAccessManager.

                        I mean some of developers advice to use the manager and not the QHttp after some new Qt version, that means tradition, but convention is will more than do.
                        So using one of QNetworkAccessManager methods you get your sms sent?[/quote]

                        Dunno. Maybe you have a look at the example the OP mentioned:

                        bq. Now I’m trying with the “http” example in qt 4.7 source (examples/network/http).

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          andre
                          wrote on last edited by
                          #12

                          [quote author="Pavel Mazniker" date="1300205130"]So using one of QNetworkAccessManager methods you get your sms sent?[/quote]
                          Errr... If you have a provider that provides such an API on the net, sure. It is not like QNetworkAccessManagers actually sends an SMS, it just sends a request to a webserver that offers an API that can send an SMS, probably to a selected range of numbers or with other restrictions.

                          1 Reply Last reply
                          0
                          • AlicemirrorA Offline
                            AlicemirrorA Offline
                            Alicemirror
                            wrote on last edited by
                            #13

                            Sure, and not in all the cases the provider - sigh - offers an api.

                            If you are interested follow the development (soruces, wiki, doc etc) of the project Naijanimi SMS that you find at http://project.forum.nokia.com/naijanimi

                            It's a similar question. The api are yet documented in the wiki pages of the project and unfortunately don't return a xml answer but strings.

                            Enrico Miglino (aka Alicemirror)
                            Balearic Dynamics
                            Islas Baleares, Ibiza (Spain)
                            www.balearicdynamics.com

                            1 Reply Last reply
                            0
                            • L Offline
                              L Offline
                              luca
                              wrote on last edited by
                              #14

                              [quote author="Andre" date="1300206235"]
                              [quote author="Pavel Mazniker" date="1300205130"]So using one of QNetworkAccessManager methods you get your sms sent?[/quote]
                              Errr... If you have a provider that provides such an API on the net, sure. It is not like QNetworkAccessManagers actually sends an SMS, it just sends a request to a webserver that offers an API that can send an SMS, probably to a selected range of numbers or with other restrictions.

                              [/quote]

                              Exactly, I'm using "www.smsmobile.it":http://www.smsmobile.it but there are a lot of other sms provider that works the same way.

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                sushant
                                wrote on last edited by
                                #15

                                how to send a sms usng way2sms or site2sms or 160by2 using Qt

                                1 Reply Last reply
                                0
                                • L Offline
                                  L Offline
                                  luca
                                  wrote on last edited by
                                  #16

                                  [quote author="sushant" date="1410097638"]how to send a sms usng way2sms or site2sms or 160by2 using Qt[/quote]

                                  Sorry but I don't know your sms provider. You should ask to the provider.
                                  In my case, smsmobile provided me an HTTP protocol to use. As described on previous messages.

                                  1 Reply Last reply
                                  0

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved