Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

How to send HTTP Headers with HTTP_Post()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to send HTTP Headers with HTTP_Post()

    I am new to the HTTP_Post function. I am needing to interact with a URL that requires me to send user name and password information along with other details. I have read the documentation on HTTP_Post but I am still unclear on how to properly format the parameters for the function. This is what I have so far:


    dim r_url as c

    var->r_url="https://my.url"

    dim req_body as C

    var->req_body = <<%body%
    API-Username=my.username
    API-Password=my.password
    Accept=text/xml
    Content-Type=text/xml
    API-Version=2.0
    %body%

    dim my_request as P

    my_request=http_post(var->r_url,var->req_body,"",80,8000,.t.)

    Is this the proper way of passing the HTTP headers? ALSO, how do I "see" what the HTTP_Post() function returns?

    Thank you for your help,
    CPGood

  • #2
    Re: How to send HTTP Headers with HTTP_Post()

    This is my boilerplace for POST, using HTTP_FETCH. I paid Alpha for this bit of code about a year ago, it was confusing to me also.

    <%a5
    dim req as p
    dim req.body as c = ""
    dim req.header as c = ""
    dim req.host as c = "gateway_domain_goes_here"
    dim req.method as c = "POST"
    dim req.page as c = "/optional_page_name_goes_here"
    dim req.ssl_on as l = .t.
    dim req.ssl_validatecert as l = .f.
    dim req.timeout as n = 10000
    dim resp as p

    req.header = <<%a%
    headers go here%a%

    req.body = <<%xml%
    request goes here. XML, pairs, whatever, example:
    <?xml version="1.0" encoding="UTF-8"?>
    <request>
    <name>Steve Wood</name>
    </request>
    %xml%

    resp = http_fetch(Req)

    dim mylocalvar as c = extract_string(resp,"start_string","end_string")

    %>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    </head>
    <body>
    <h2>Response</h2>
    <pre><%a5 ? strtran(resp.headers + crlf(2) + resp.body,"<","&lt;") %></pre>
    </body></html>
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

    Comment


    • #3
      Re: How to send HTTP Headers with HTTP_Post()

      Hi Steve,

      Thank you! I will study this and learn to use it.

      First question ... at the very beginning you have a "<%a5" that appears to not have a "closing" or end. Is this okay? or has the closing marker been omitted?

      CPGood

      Comment


      • #4
        Re: How to send HTTP Headers with HTTP_Post()

        The <%a5 closes just above the DOCTYPE line. Mine is for web, you posted in Desktop, so you might need to modify it for your environment.
        Steve Wood
        Join the ALPHA DEVELOPERS NETWORK
        There is no Cloud. It's just someone else's computer.
        Web - Mobile - Hosting - Products - Frameworks - Developer Resources
        AlphaToGo | IADN (100% Alpha Anywhere Websites)

        Comment


        • #5
          Re: How to send HTTP Headers with HTTP_Post()

          How is this method completed with the Request and response for Paypals adaptive payments API? A sample request and Response from the apigee console is quoted below.
          Tks
          Bob

          https://apigee.com/console/paypal#

          Steve's Code
          <%a5
          dim req as p
          dim req.body as c = ""
          dim req.header as c = ""
          dim req.host as c = "gateway_domain_goes_here"
          dim req.method as c = "POST"
          dim req.page as c = "/optional_page_name_goes_here"
          dim req.ssl_on as l = .t.
          dim req.ssl_validatecert as l = .f.
          dim req.timeout as n = 10000
          dim resp as p

          req.header = <<%a%
          headers go here%a%

          req.body = <<%xml%
          request goes here. XML, pairs, whatever, example:
          <?xml version="1.0" encoding="UTF-8"?>
          <request>
          <name>Steve Wood</name>
          </request>
          %xml%

          resp = http_fetch(Req)

          dim mylocalvar as c = extract_string(resp,"start_string","end_string")

          %>

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
          <html>
          <head>
          <title></title>
          </head>
          <body>
          <h2>Response</h2>
          <pre><%a5 ? strtran(resp.headers + crlf(2) + resp.body,"<","&lt;") %></pre>
          </body></html>
          Request
          POST /AdaptivePayments/Pay HTTP/1.1

          X-PAYPAL-APPLICATION-ID:
          APP-80W284485P519543T
          X-HostCommonName:
          svcs.sandbox.paypal.com
          Host:
          svcs.sandbox.paypal.com
          Content-Length:
          346
          X-PAYPAL-SECURITY-PASSWORD:
          1308012415
          X-PAYPAL-REQUEST-SOURCE:
          APIGEE-CONSOLE-1.0
          X-Target-URI:
          https://svcs.sandbox.paypal.com
          X-PAYPAL-SECURITY-SIGNATURE:
          AwtA9lQSPLeWROOJ9frsiqt5B-vPAnMPxFQ9yR22UND4.cBU93kMoRSh
          Connection:
          Keep-Alive
          X-PAYPAL-REQUEST-DATA-FORMAT:
          JSON
          X-PAYPAL-DEVICE-IPADDRESS:
          127.0.0.1
          X-Forwarded-For:
          10.203.10.109
          Content-Type:
          text/plain; charset=ISO-8859-1
          X-PAYPAL-SECURITY-USERID:
          bobsen_1308012402_biz_api1.aol.com
          X-PAYPAL-RESPONSE-DATA-FORMAT:
          JSON


          {
          "actionType":"PAY",
          "currencyCode":"USD",
          "receiverList":{"receiver":[{"amount":"1.00","email":"seller_1288085303_biz@gmail.com"}]},
          "returnUrl":"http://apigee.com/console/-1/handlePaypalReturn",
          "cancelUrl":"http://apigee.com/console/-1/handlePaypalCancel?",
          "requestEnvelope":{"errorLanguage":"en_US", "detailLevel":"ReturnAll"}
          }
          Response

          HTTP/1.1 200 OK

          X-PAYPAL-SERVICE-VERSION:
          1.0.0
          Content-Length:
          194
          X-PAYPAL-OPERATION-NAME:
          Pay
          Set-Cookie:
          Apache=10.191.196.11.1308017198048517; path=/; expires=Sun, 30-Apr-05 19:38:22 GMT
          Connection:
          close
          X-EBAY-SOA-MESSAGE-PROTOCOL:
          NONE
          Server:
          Apache-Coyote/1.1
          X-EBAY-SOA-REQUEST-ID:
          1308be68-42b0-abfc-49a1-bef1fffd9ddb!AdaptivePayments!10.191.196.154![]
          Date:
          Tue, 14 Jun 2011 02:06:38 GMT
          Vary:
          Accept-Encoding
          X-PAYPAL-SERVICE-NAME:
          {http://svcs.paypal.com/types/ap}AdaptivePayments
          X-EBAY-SOA-RESPONSE-DATA-FORMAT:
          JSON
          Content-Type:
          application/json;charset=UTF-8


          {
          "responseEnvelope": {
          "timestamp" : "2011-06-13T19:06:38.307-07:00",
          "ack" : "Success",
          "correlationId" : "448c39688e64f",
          "build" : "1867348"
          },
          "payKey" : "AP-8FT77744563084349",
          "paymentExecStatus" : "CREATED"
          }
          Last edited by bob9145; 06-13-2011, 10:43 PM.

          Comment


          • #6
            Re: How to send HTTP Headers with HTTP_Post()

            Is there something specific you need from the more complex Adaptive Payments API that you can't get with their Web Payment Standard API?
            Steve Wood
            Join the ALPHA DEVELOPERS NETWORK
            There is no Cloud. It's just someone else's computer.
            Web - Mobile - Hosting - Products - Frameworks - Developer Resources
            AlphaToGo | IADN (100% Alpha Anywhere Websites)

            Comment


            • #7
              Re: How to send HTTP Headers with HTTP_Post()

              Yes,
              My app requires a combination of split and chained payments. I also wanted to learn how to integrate an API with Alpha as it applies to a payment gateway. I'm having some trouble getting my head around this.

              From what I gather I need and a5w page to send each request and one to receive, parse and save the response?

              Adaptive payments opens up the door to many creative ways to facilitate creative payments. Monies can be combined or split, fees can be split. This could facilitate many different new webapp driven business models.

              Tks,
              Bob
              Last edited by bob9145; 06-14-2011, 12:15 PM.

              Comment


              • #8
                Re: How to send HTTP Headers with HTTP_Post()

                Adaptive Payments is truly superior to the Payment Standard. I also want to eventually use it for Affiliates, to split up receipts as you say.

                You can use two pages or one. The same page that sends the request can listen for the response. The API is ascronous so you never know when the response will come, though normally right away. So you have to ensure the response has some value you recognize like your own TransID or OrderID. The response comes in as XML/SOAP and you can use Alpha's XML Parser (which I don't know how to use) or simple extract_string() to parse out what you get.
                Steve Wood
                Join the ALPHA DEVELOPERS NETWORK
                There is no Cloud. It's just someone else's computer.
                Web - Mobile - Hosting - Products - Frameworks - Developer Resources
                AlphaToGo | IADN (100% Alpha Anywhere Websites)

                Comment


                • #9
                  Re: How to send HTTP Headers with HTTP_Post()

                  Thanks Steve,

                  Maybe Lenny can put together an example of this for us when he has time? He's turned up in most of my searches and seems to be the HTTP/API Guru. There are lots of small pieces to what appears to be one of those one thousand piece jigsaw puzzles.

                  A few a5w pages with a grid component slapped on them, that included the code to send, receive, and parse API calls/responses and logs them to a dbf table would lead me out of this deep dark cave.

                  I am running out of torch oil, and I just past a skeleton clutching half a yellowed print out of a google map.

                  Lenny Help!

                  Comment


                  • #10
                    Re: How to send HTTP Headers with HTTP_Post()

                    Bob, everything you need is in my example a few posts ago, re-quoted by you. It shows the request (req.body), listening for the response (resp), and parsing the data (extract_string(resp,a,b)). I was a little reluctant to provide that code as I had paid Lenny (via Alpha Software) a year ago $500 for what you see there. I am sure that Lenny would not be able to provide such a complete example unless you open a support ticket with Alpha as well.

                    In order to figure out how to use the PayPal Payment Standard API, I printed out their entire API and IPN reference and slogged through it. A few others here have done the same. It is not easy, and Adaptive Payments is harder than Payment Standard.
                    Steve Wood
                    Join the ALPHA DEVELOPERS NETWORK
                    There is no Cloud. It's just someone else's computer.
                    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
                    AlphaToGo | IADN (100% Alpha Anywhere Websites)

                    Comment


                    • #11
                      Re: How to send HTTP Headers with HTTP_Post()

                      Thanks again Steve,
                      I appreciate you sharing something you paid for. If I can adapt it for adaptive s I will return the favor, however I wouldn't hold your breath. LOL
                      Bob

                      Comment


                      • #12
                        Re: How to send HTTP Headers with HTTP_Post()

                        Bob, I'll even work with you on it when I get a chance.
                        Steve Wood
                        Join the ALPHA DEVELOPERS NETWORK
                        There is no Cloud. It's just someone else's computer.
                        Web - Mobile - Hosting - Products - Frameworks - Developer Resources
                        AlphaToGo | IADN (100% Alpha Anywhere Websites)

                        Comment


                        • #13
                          Re: How to send HTTP Headers with HTTP_Post()

                          Great,
                          I'll post any progress I make.
                          Tks

                          Comment


                          • #14
                            Re: How to send HTTP Headers with HTTP_Post()

                            Hi Steve,

                            With your help I have gotten the http_fetch going and used it on several projects. I would like to write the responses that come back from the http_fetch to a data table. I am getting errors when I try to write the .parsed_headers.status_code and the .body variables to data fields. I have defined two data fields to hold these values. The fields are both of type character. I am using the following method (this returns an error):

                            data_tbl.response_status_code=fetch_resp.parsed_headers.status_code
                            data_tbl.response_body=fetch_resp.body

                            where data_tbl = my data table
                            where fetch_resp = the result of my http_fetch

                            I figure that I must need to do some form of transformation to get the variable data into a text variable and then write the text variable to the data fields. But I cannot figure this out.

                            Thank you in advance for your help if you can give me a tip,

                            CPGood

                            Comment

                            Working...
                            X