Request External Password protected XML information and parse to my Classic ASP page - asp.net

I am in charge of Web Design and Marketing for the company I work for. I kind of got thrown into the role of Coding.
We use an eCommerce software to help with site structure and product information. This site uses Classic ASP to form all pages in order to make the process easier.
Well now I have been given an XML Data Feed instructions, but I have no idea where to begin. I have read some different posts, but none really give examples of what I am trying to do.
What I need to do is submit a request to "https://ec.synnex.com/SynnexXML/PriceAvailability" which is password protected and get the return xml.
Request sent to https://ec.synnex.com/SynnexXML/PriceAvailability using below xml:
<?xml version="1.0" encoding="UTF-8" ?>
<priceRequest>
<customerNo>YOUR_ID</customerNo>
<userName>USERNAME</userName>
<password>PASSWORD</password>
<skuList>
<mfgPN>PRODUCTPARTNUMBER</mfgPN>
<lineNumber>1</lineNumber>
</skuList>
</priceRequest>
and it will return the xml:
<?xml version="1.0" encoding="UTF-8" ?>
<priceResponse>
<customerNo>YOUR ACCOUNT NUMBER</customerNo>
<userName>YOUR ID</userName>
<PriceAvailabilityList>
<mfgPN>108R00645</mfgPN>
<mfgCode>13439</mfgCode>
<status>Active</status>
<description>IMAGING UNIT, PHASER 6300/6350</description>
<GlobalProductStatusCode>Active</GlobalProductStatusCode>
<price>228.48</price>
<totalQuantity>240</totalQuantity>
<AvailabilityByWarehouse>
<warehouseInfo>
<number>3</number>
<zipcode>94538</zipcode>
<city>Fremont, CA</city>
<addr>44211 Nobel Drive</addr>
</warehouseInfo>
<qty>30</qty>
</AvailabilityByWarehouse>
<AvailabilityByWarehouse>
<warehouseInfo>
<number>4</number>
<zipcode>30071</zipcode>
<city>Norcross, GA</city>
<addr>200 Best Friend Court, Suite# 250</addr>
</warehouseInfo>
<qty>27</qty>
</AvailabilityByWarehouse>
<AvailabilityByWarehouse>
<warehouseInfo>
<number>5</number>
<zipcode>75081</zipcode>
<city>Richardson, TX</city>
<addr>660 N Dorothy Drive, Suite 100</addr>
</warehouseInfo>
<qty>2</qty>
</AvailabilityByWarehouse>
<lineNumber>1</lineNumber>
</PriceAvailabilityList>
</priceResponse>
I have no idea even where to even begin with this.
Once I get the information sent and it comes back I'm sure I can assign a Dim Value and then use the call for the value in the code I already have for displaying our products. <%=whatevervalue%>
Any help would be much appreciated.

Related

Adding User Defined Interface Data (UDID) to Sabre PNR

I'm trying to add UDID fields to PNRs using the SOAP API. There is no mention of such functionality anywhere in the docs!
So I tried using the SabreCommandLLSRQ endpoint to attach the UD fields, but I don't seem to be able to make any changes, despite receiving a * response.
I've tried the following command using the endpoint:
5.S*RL[record locator]*UD56 [some test value]
For example:
5.S*RLEPLHYN*UD56 YVRYEG
But that also leads to a * response without the PNR actually changing.
Are you sure that's the right UDID format? I've never seen a record locator prepended to a UDID before. If using the SabreCommandLLSRQ endpoint I would expect your format to look like this:
5.S*UD56 [some test value]
There are many UDID formats so I may be wrong there and I know the responses can be quirky. What response do you get in a PNR if you simply enter your format into Sabre Red?
There is also support for itin remarks in the Add Itinerary Remark (AddRemarkLLSRQ), which may be worth implementing for you as well.
I found it in the API too, it is only mentioned in one of many examples in AddRemarkRQ:
If you want it to show up on the itinerary:
<AddRemarkRQ xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.1.1">
<RemarkInfo>
<Remark Type="Invoice">
<Text>
U45-111794
</Text>
</Remark>
</RemarkInfo>
</AddRemarkRQ>
If you don't want it to show up on the itinerary:
<AddRemarkRQ xmlns="http://webservices.sabre.com/sabreXML/2011/10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.1.1">
<RemarkInfo>
<Remark Type="Invoice">
<Text>
U*45-111794
</Text>
</Remark>
</RemarkInfo>
</AddRemarkRQ>
I've tested it in both CreatePassengerNameRecordRQ and AddRemarkRQ contexts.

Extending twilio plugin to work with WordPress REST API

I've worked through the twilio tutorials regarding sending and receiving SMS with WordPress. I integrated them into a test install I have and then merged them into one. (The receive one is pretty short, although it's not a full "receive" more than a blind response).
Then I came across themebound's twilio-core and so I had a look at that and quickly I got a fatal error because they both use the twilio helper library. For testing, I just deactivated the first one and activated the second, which leads me into my first question:
Both of these use the same library, and have both used require_once. Each loaded it into their own plugin folder. The original name of the library is twilio-php-master, one renames it twilio the other twilio-php. Not that it matters at all, since they're in separate locations. The fatal error is as a result of the inner workings having the same function names.
How can I test for the existence of the other plugins helper library and use that in place of the one that I have installed?
What about the order of how WordPress loads the plugins? It's likely if mine loads first... Well, I can't even get that far because it crashes just trying to have both activated.
--- we're now leading into the next question ---
As a result, I'm probably going to go with the twilio-core version because it seems more featured and is available on github, even if the author isn't overly active (there's a pull request that's months old and no discussion about it).
I want to extend the functionality of one of the sending plugins (either one) with respect to the receipt of the message from twilio. At the moment, both examples use classes for the sending and the receive that I'm using is not. As such I have just added it to the end of the main plugin file (the one with the plugin metadata). (a quick note, this is not the cause of the above fatal error, this happened before I started merging the send and receive).
Because the receive is involved with the REST API and not initiated by a user action on the system (ie someone in the admin area accessing the class through the admin panel), I'm not sure if it's appropriate that a) I put it there, and b) use the send function inside the class when further processing the receipt. I have an end goal of analysing the incoming message and forwarding it back out through twilio or other application or even just recording it in wordpress itself.
Should I keep the receive functionality/plugin separate from the sending one?
And this leads on to the hardest question for me:
How would I extend either plugin to make the send function available to my receive plugin? (this is where part of my confusion comes from) -->> Because both plugins only operate in the admin area, and the REST API isn't an actual user operating in the front-end, how can I call those functions in the admin area? Will is "just be available"? Do I have to replicate them on the public side? and then if so, is it necessary to have it in the admin area as well?
edit: With respect to one of the comments below, I have tested and twl_send_sms is available once the helper is loaded. What I will do is determine a way to see if the helper is loaded (a function exists test will probably suffice) and if so, require or not require my version as appropriate.
From the receive message I am now able to craft a separate forward of a new message. But how can I pass the callback function the parameters of the initial inbound message? eg, how do I populate $sms_in with the POST data?
function register_receive_message_route() {
register_rest_route( 'sms/v1', '/receiver_sms', array(
'methods' => 'POST',
'callback' => 'trigger_receive_sms',
) );
}
function trigger_receive_sms($sms_in = '') {
/* we have three things to do:
* 1: send the reply to twilio,
* 2: craft a reply,
* 3: save the data message to the database
*/
echo header('content-type: text/xml');
echo ('<?xml version="1.0" encoding="UTF-8"?>');
echo ('<Response>');
echo (' <Message>Thanks, someone will be in contact shortly.</Message>');
echo ('</Response>');
$args = array(
'number_to' => '+xxxxxxxxxxx',
'message' => "Test Worked!\n$sms_in",
);
twl_send_sms( $args );
Twilio developer evangelist here.
It sounds to me as though your send functionality (whatever you can get out of twilio-core) is separate to your receive functionality. So I would likely split those up as two plugins and follow the instructions from the post you mentioned on how to write something that receives and responds to SMS messages. That way, twilio-core can use the Twilio library it bundles and your receive plugin won't need to use a library (it just needs to respond with TwiML, which is just XML).
I'm not sure I understand the last part of question 4 though, you can't really interact yourself with the receive endpoint of the plugin because all it will do is return XML to you. That's for Twilio to interact with.
Edit
In answer to your updated question, when your callback is triggered by a POST request it is passed a WP_REST_Request object. This object contains the POST body and the parameters can be accessed by array access.
function trigger_receive_sms($request) {
echo $request['Body'];
}
In good news, if you just plan to send two messages then you can do so entirely with TwiML. You just need to use two <Message>s:
echo ('<?xml version="1.0" encoding="UTF-8"?>');
echo ('<Response>');
echo (' <Message>Thanks, someone will be in contact shortly.</Message>');
echo (' <Message to="YOUR_OTHER_NUMBER">It worked!</Message>');
echo ('</Response>');
This way you don't need to worry about that other library.

Log in to website using Jsoup

I'm trying to scrap a webpage for data but came across the problem of needing to log in.
Connection.Response loginForm = Jsoup.connect("http://www.rapidnyc.net/users/google_login")
.method(Connection.Method.GET)
.execute();
Document document = Jsoup.connect("http://www.rapidnyc.net/users/google_login")
.data("Email", "testEmail")
.data("Passwd", "testPass")
.... //other form data
.cookies(loginForm.cookies())
.post();
This gives me the org.jsoup.HttpStatusException: HTTP error fetching URL. Status=400
I used chrome developer tool to look at the Form data being posted but nothing I post works.
1. Have you submitted ALL input fields? Including HIDDEN ones.
2. I see the website requires "captcha-box" authentication, which is to prevent web crawlers from logging in. I highly doubt you will be able to log in with your program.
I say the 400 status is coming from your program not being able to provide the value for "captcha" authentication.

How to pull Deposits from QuickBooksOnline using IntuitAnywhere

I am attempting to pull all the General Ledger entries from QuickBooksOnline into my C# Asp.net application for a given date range. I have been able to successfully pull Bills, Checks, and JournalEntries that match the Profit and Loss Detail report I'm using for reference. However, I seem to be missing all "Deposit" types from that report. I am pulling data for Invoices and Payments but they are coming back empty for the TxnDates I'm looking for.
In case it helps I'm including the Request and Response xml logs for Invoices and Payments.
Invoice Request
Filter=TxnDate :AFTER: 2013-02-28T00:00:00-05:00 :AND: TxnDate :BEFORE: 2013-04-01T00:00:00-04:00&PageNum=1&ResultsPerPage=100
Invoice Response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><qbo:SearchResults xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:qbp="http://www.intuit.com/sb/cdm/qbopayroll/v1" xmlns:qbo="http://www.intuit.com/sb/cdm/qbo"><qbo:CdmCollections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Invoices"/><qbo:Count>0</qbo:Count><qbo:CurrentPage>1</qbo:CurrentPage></qbo:SearchResults>
Payment Request
Filter=TxnDate :AFTER: 2013-02-28T00:00:00-05:00 :AND: TxnDate :BEFORE: 2013-04-01T00:00:00-04:00&PageNum=1&ResultsPerPage=100
Payment Response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><qbo:SearchResults xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:qbp="http://www.intuit.com/sb/cdm/qbopayroll/v1" xmlns:qbo="http://www.intuit.com/sb/cdm/qbo"><qbo:CdmCollections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Payments"/><qbo:Count>0</qbo:Count><qbo:CurrentPage>1</qbo:CurrentPage></qbo:SearchResults>
Deposits are not the same thing as an invoice or a payment. Deposits are a separate transaction indicating a deposit of a payment, to the bank.
According to Intuit's documentation, querying for deposits is not supported by the v2 APIs.

I want to port my delicious bookmarks to my website

I started building a app that will automatically download my delicious bookmarks, and save to a database, so they I can view them on my own website in my favoured format.
I am forced to use oAuth, as I have a yahoo id to login to delicious. The problem is I am stuck at the point where oAuth requires a user to manually go and authenticate.
Is there a code/ guidelines available anywhere I can follow? All I want is a way to automatically save my bookmarks to my database.
Any help is appreciated. I can work on java, .net and php. Thanks.
Delicious Provides an API for this already:
https://api.del.icio.us/v1/posts/all?
Returns all posts. Please use sparingly. Call the update function to see if you need to fetch this at all.
Arguments
&tag={TAG}
(optional) Filter by this tag.
&start={#}
(optional) Start returning posts this many results into the set.
&results={#}
(optional) Return this many results.
&fromdt={CCYY-MM-DDThh:mm:ssZ}
(optional) Filter for posts on this date or later
&todt={CCYY-MM-DDThh:mm:ssZ}
(optional) Filter for posts on this date or earlier
&meta=yes
(optional) Include change detection signatures on each item in a 'meta' attribute. Clients wishing to maintain a synchronized local store of bookmarks should retain the value of this attribute - its value will change when any significant field of the bookmark changes.
Example
$ curl https://user:passwd#api.del.icio.us/v1/posts/all
<posts tag="" user="user">
<post href="http://www.weather.com/" description="weather.com"
hash="6cfedbe75f413c56b6ce79e6fa102aba" tag="weather reference"
time="2005-11-29T20:30:47Z" />
...
<post href="http://www.nytimes.com/"
description="The New York Times - Breaking News, World News & Multimedia"
extended="requires login" hash="ca1e6357399774951eed4628d69eb84b"
tag="news media" time="2005-11-29T20:30:05Z" />
</posts>
There are also public and private RSS feeds for bookmarks, so if you can read and parse XML you don't necessarily need to use the API.
Note however that if you registered with Delicious after December, and therefore use your Yahoo account, the above will not work and you'll need to use OAuth.
There are a number of full examples on the Delicious support site, see for example: http://support.delicious.com/forum/comments.php?DiscussionID=3698

Resources