Is there any service returning ZIP Codes on given city/satate? - geolocation

is there any server available that i can use for getting zip codes on the basis on city/state ?
Thanks

You can use geonames postal code search. For example:
http://ws.geonames.org/postalCodeSearch?adminCode1=CA&placename=San+Francisco&maxRows=3
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<geonames>
<totalResultsCount>76</totalResultsCount>
<code>
<postalcode>94102</postalcode>
<name>San Francisco</name>
<countryCode>US</countryCode>
<lat>37.781334</lat>
<lng>-122.416728</lng>
<adminCode1>CA</adminCode1>
<adminName1>California</adminName1>
<adminCode2>075</adminCode2>
<adminName2>San Francisco</adminName2>
<adminCode3/>
<adminName3/>
</code>
<code>
<postalcode>94103</postalcode>
<name>San Francisco</name>
<countryCode>US</countryCode>
<lat>37.77254</lat>
<lng>-122.414664</lng>
<adminCode1>CA</adminCode1>
<adminName1>California</adminName1>
<adminCode2>075</adminCode2>
<adminName2>San Francisco</adminName2>
<adminCode3/>
<adminName3/>
</code>
<code>
<postalcode>94107</postalcode>
<name>San Francisco</name>
<countryCode>US</countryCode>
<lat>37.762147</lat>
<lng>-122.397099</lng>
<adminCode1>CA</adminCode1>
<adminName1>California</adminName1>
<adminCode2>075</adminCode2>
<adminName2>San Francisco</adminName2>
<adminCode3/>
<adminName3/>
</code>
</geonames>

You can use the US Postal Service HTTP/XML API
According to this page on the US Postal Service website which documents their XML based web API, specifically Section 3.0 (page 13) of this PDF document, they have a URL where you can send an XML request containing an address minus the Zip Code and they will respond with an XML document containing the complete address.
You can't do a lookup with just a city and state though, because a single city can contain multiple ZIP codes, so you need to pass the street address as well.
According to their documentation, this is what your request would look like:
GET http://SERVERNAME/ShippingAPITest.dll?API=ZipCodeLookup&XML=<ZipCodeLookupRequest%20USERID="xxxxxxx"><Address ID="0"><Address1></Address1> <Address2>6406 Ivy Lane</Address2><City>Greenbelt</City><State>MD</State></Address></ZipCodeLookupRequest>
And here's what you would receive back:
<?xml version="1.0"?>
<ZipCodeLookupResponse>
<Address ID="0">
<Address2>6406 IVY LN</Address2>
<City>GREENBELT</City>
<State>MD</State>
<Zip5>20770</Zip5>
<Zip4>1441</Zip4>
</Address>
</ZipCodeLookupResponse>
USPS does require that you register with them before you can use the API, but, as far as I could tell, there is no charge for access. By the way, their API has some other features: you can do Address Standardization and Zip Code Lookup, as well as the whole suite of tracking, shipping, labels, etc.

Related

In some cases, Graph API's "ical_uid" value differs from EWS "UID" for the same CalendarItem/event

We use EWS to bi-directionally synchronize Exchange events with our application, and we are in the process of migrating to Graph API.
When creating reservations in Exchange through EWS using CreateItem, we set the uid using a self-generated UUID like this (look at the "UID" field) :
<?xml version=\'1.0\' encoding=\'utf-8\'?>\n
<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft. com/exchange/services/2006/types">
<s:Header>
<t:RequestServerVersion Version="Exchange2016"/>
<t:TimeZoneContext>
<t:TimeZoneDefinition Id="Romance Standard Time"/>
</t:TimeZoneContext>
</s: Header>
<s:Body>
<m:CreateItem MessageDisposition="SaveOnly" SendMeetingInvitations="SendToAllAndSaveCopy">
<m:SavedItemFolderId>
<t:DistinguishedFolderId Id="calendar">
<t:Mailbox>
<t: EmailAddress>email#email.com
</t:EmailAddress>
<t:RoutingType>SMTP</t:RoutingType>
<t:MailboxType>Mailbox</t:MailboxType>
</t:Mailbox>
</t:DistinguishedFolderId>
</m:SavedItemFolderId>
<m: Items>
<t:CalendarItem>
<t:Subject>subject</t:Subject>
<t:Sensitivity>Normal</t:Sensitivity>
<t:Body BodyType="HTML"></t:Body>
<t:Importance>Normal</t:Importance>
<t:ReminderIsSet>0
</t: ReminderIsSet>
<t:ReminderMinutesBeforeStart>0</t:ReminderMinutesBeforeStart>
--> <t:UID>81d5f321-af6c-45ae-9cac-ef096ef32069</t:UID>
<t:Start>2022-07-28T17:00:00+02:00</t:Start>
<t: End>2022-07-28T17:30:00+02:00
</t:End>
<t:IsAllDayEvent>0</t:IsAllDayEvent>
<t:LegacyFreeBusyStatus>Busy</t:LegacyFreeBusyStatus>
<t:Location></t:Location>
<t:Resources>
<t:Waitee>
<t:Mailbox>
<t: EmailAddress>resource_email#email.com
</t:EmailAddress>
<t:RoutingType>SMTP</t:RoutingType>
<t:MailboxType>Mailbox</t:MailboxType>
</t:Mailbox>
<t:ResponseType>Accept</t:ResponseType>
</t: Attendee>
</t:Resources>
<t:StartTimeZone Id="Romance Standard Time" Name=""/>
<t:EndTimeZone Id="Romance Standard Time" Name=""/>
</t:CalendarItem>
</m:Items>
</m:CreateItem>
</s:Body>
</s:Envelope>
This identifier seems to be fully supported by Exchange:
When this event comes back to our application as a result of a "GetItem" SOAP request, it has the same identifier 81d5f321-af6c-45ae-9cac-ef096ef32069
When I look at the MAPI properties of the event using the OutlookSpy tool, I find our UUID in the "GlobalObjectId" and "CleanGlobalObjectId" fields
However, when we synchronize this same event using Graph API, the ical_uid field is totally different, which generates synchronization problems in our application following the EWS->Graph API migration.
To add some information:
Using the beta version of Graph API, we get a "uid" field that contains our UUID.
When the event is created on Outlook, it is a UID generated by EWS and not by our application, there is no such problem
How can I make sure I get the same UID as with EWS and avoid synchronization problems?

AccountKey in sData

Myself and two other people that are trying to communicate with Sage Accounting using sData, but perhaps someone has used sData.
I'm trying to post sData to our Sage server and create a deposit transaction that will show up in the bank reconciliation. I've tried tons of different variations, but this is what the sData looks like that I am currently posting to the server.
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005"
xmlns="http://www.w3.org/2005/Atom"
xmlns:sdata="http://schemas.sage.com/sdata/2008/1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"
xmlns:sync="http://schemas.sage.com/sdata/sync/2008/1"
xmlns:sme="http://schemas.sage.com/sdata/sme/2007"
xmlns:http="http://schemas.sage.com/sdata/http/2008/1">
<sdata:payload>
<GL_TransactionJournalHeader sdata:uri="/sdata/MasApp/MasContract/TS2/GL_TransactionJournalHeaderSPECIAL()" xmlns="">
<PostingDate>2018-02-16</PostingDate>
<SourceJournal>BR</SourceJournal>
<AcceptOutOfBalance>N</AcceptOutOfBalance>
<TransactionType>D</TransactionType>
<JournalDeleted>N</JournalDeleted>
<JournalComment>If this works it will be a miracle!</JournalComment>
<JournalType>F</JournalType>
<Offset>C</Offset>
<OffsetAccountKey>000000034</OffsetAccountKey>
<JournalTotal>5.0000</JournalTotal>
<GL_TransactionJournalDetail>
<PostingComment>Test line comment</PostingComment>
<DebitAmount>5.00</DebitAmount>
<CreditAmount>0.00</CreditAmount>
<TransactionType>D</TransactionType>
<AccountKey>000000005</AccountKey>
</GL_TransactionJournalDetail>
</GL_TransactionJournalHeader>
</sdata:payload>
</entry>
I've tried posting more than this and less than this. I've tried adding it in line by line and I always get an error when I add the AccountKey using a valid Sage Account Key. If I use an invalid Account Key the error message says that the account is invalid, this is what the server returns when the account key is valid.
<?xml version="1.0" encoding="utf-8"?>
<sdata:diagnoses xmlns="http://schemas.sage.com/sdata/2008/1" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sdata="http://schemas.sage.com/sdata/2008/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:sync="http://schemas.sage.com/sdata/sync/2008/1" xmlns:sme="http://schemas.sage.com/sdata/sme/2007" xmlns:http="http://schemas.sage.com/sdata/http/2008/1">
<sdata:diagnosis>
<sdata:severity>error</sdata:severity>
<sdata:sdataCode>ApplicationDiagnosis</sdata:sdataCode>
<sdata:applicationCode />
<sdata:message> is not on file.Š</sdata:message>
<sdata:stackTrace />
<sdata:payloadPath />
</sdata:diagnosis>
</sdata:diagnoses>
I've seen posts on other forums but the answer was "no one uses sData". While this is likely true, it doesn't really solve my problem. I'm stuck with sData for the time being. Has anyone seen this sort of error before and have any suggestions on how to fix it?
So the error I was getting wasn't complaining about the AccountKey not on file it was complaining about the Bank Code not being included. I added the BankCode and then the DepositNo and the transaction posted successfully.
<sdata:payload>
<GL_TransactionJournalHeaderSPECIAL sdata:uri="/sdata/MasApp/MasContract/TS2/GL_TransactionJournalHeaderSPECIAL()" xmlns="">
<PostingDate>2018-02-16</PostingDate>
<SourceJournal>BR</SourceJournal>
<AcceptOutOfBalance>N</AcceptOutOfBalance>
<TransactionType>D</TransactionType>
<JournalDeleted>N</JournalDeleted>
<JournalComment>If this works it will be a miracle!</JournalComment>
<JournalType>F</JournalType>
<BankCode>B</BankCode>
<DepositNo>123</DepositNo>
<Offset>C</Offset>
<OffsetAccountKey>000000034</OffsetAccountKey>
<JournalTotal>5.0000</JournalTotal>
<GL_TransactionJournalDetail>
<BankCode>B</BankCode>
<PostingComment>Test line comment</PostingComment>
<DebitAmount>5.00</DebitAmount>
<CreditAmount>0.00</CreditAmount>
<TransactionType>D</TransactionType>
<AccountKey>000000005</AccountKey>
</GL_TransactionJournalDetail>
</GL_TransactionJournalHeaderSPECIAL>
</sdata:payload>

Quickbooks API and detecting deleted items

I'm using the Quickbooks XML API to import salesorders, items, and customers. Everything works great, however I haven't figured out how to handle things that are deleted in Quickbooks. Querying the imported data in my system is not an option because I have 20,000+ salesorders. My question is, does Quickbooks have a query for deleted items?
QuickBooks for Windows:
If you're using QuickBooks for Windows, then you can do a TxnDeletedQueryRq request to get a list of recently deleted transactions.
Example:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="9.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<TxnDeletedQueryRq>
<!-- TxnDelType may have one of the following values: ARRefundCreditCard, Bill, BillPaymentCheck, BillPaymentCreditCard, BuildAssembly, Charge, Check, CreditCardCharge, CreditCardCredit, CreditMemo, Deposit, Estimate, InventoryAdjustment, Invoice, ItemReceipt, JournalEntry, PayrollLiabilityAdjustment [PRIVATE], PayrollPriorPayment [PRIVATE], PayrollYearToDateAdjustment [PRIVATE], PurchaseOrder, ReceivePayment, SalesOrder, SalesReceipt, SalesTaxPaymentCheck, TimeTracking, TransferInventory, VehicleMileage, VendorCredit -->
<TxnDelType>Invoice</TxnDelType>
<TxnDelType>ReceivePayment</TxnDelType>
</TxnDeletedQueryRq>
</QBXMLMsgsRq>
</QBXML>
Example from here:
http://www.consolibyte.com/docs/index.php/QbXML_for_Querying_for_Deleted_Objects
http://www.consolibyte.com/docs/index.php/Example_qbXML_Requests
The full syntax with all options/flags you can set can be found in the QuickBooks OSR:
https://developer-static.intuit.com/qbSDK-current/Common/newOSR/index.html
QuickBooks Online:
If you're using QuickBooks Online, then you can use the CDC requests to poll for recently changed data, including things that have been deleted.
https://quickbooks.api.intuit.com/v3/company/1234/cdc?entities=Class,Item,Invoice&changedSince=2012-07-20T22:25:51-07:00
Will return something like:
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2013-04-03T10:36:19.393Z">
<CDCResponse>
<QueryResponse>
<Customer>...
</Customer>
...
Some of which may have a status="Deleted" attribute to let you know it's been deleted.

Sending an order into Quickbooks via IPP doesn't work when transaction date is in the past

I've edited the question to make it more clean and focused now that I've investigated more.
Syncing orders are working for today's date and future dates, but not for dates in the past. I'm testing now directly in the API explorer.
Here is the add order request and response:
<!--Add order request-->
<Add xmlns="http://www.intuit.com/sb/cdm/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
RequestId="ecc53f53d70f0a52de4c88021721ba32"
xsi:schemaLocation="http://www.intuit.com/sb/cdm/v2 ./RestDataFilter.xsd ">
<OfferingId>ipp</OfferingId>
<ExternalRealmId>688875295</ExternalRealmId>
<Object xsi:type="SalesOrder">
<Header>
<DocNumber>6</DocNumber>
<TxnDate>2010-12-25</TxnDate>
<CustomerId idDomain="QB">4</CustomerId>
<SalesRepId idDomain="QB">1</SalesRepId>
</Header>
<Line>
<ItemId idDomain="QB">1</ItemId>
<Qty>6</Qty>
</Line>
</Object>
</Add>
<!--Add order response-->
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2">
<Success RequestId="ecc53f53d70f0a52de4c88021721ba32">
<ObjectRef>
<Id idDomain="NG">802721</Id>
<SyncToken>1</SyncToken>
<LastUpdatedTime>2013-04-29T15:26:53Z</LastUpdatedTime>
</ObjectRef>
<RequestName>SalesOrderAdd</RequestName>
<ProcessedTime>2013-04-29T15:26:53Z</ProcessedTime>
</Success>
</RestResponse>
Here is the sync status and sync activity. There was only one entity with SalesOrder, but the times don't match up, so I don't believe its referencing the same order that I added via API explorer. Also, the order that I added did not appear in Quickbooks also.
<SyncStatusResponse>
<NgIdSet>
<NgId>802721</NgId>
<NgObjectType>SalesOrder</NgObjectType>
</NgIdSet>
<RequestId>DB7F4BF877006079E040900A0F1B14C1</RequestId>
<StateCode>8</StateCode>
<StateDesc>Record netted with QB</StateDesc>
<MessageCode>70</MessageCode>
<MessageDesc>MBL Netter success using QB SDK ext_ack_id</MessageDesc>
<ResponseLogTMS>2013-04-29T15:38:02.0Z</ResponseLogTMS>
</SyncStatusResponse>
<SyncActivityResponse>
<SyncType>Writeback</SyncType>
<StartSyncTMS>2013-04-10T12:42:21.0</StartSyncTMS>
<EndSyncTMS>2013-04-29T08:38:02.0</EndSyncTMS>
<EntityName>SalesOrder</EntityName>
<EntityRowCount>20</EntityRowCount>
</SyncActivityResponse>
From the sync status response, state code 8 means
Record netted. Synchronized. Object created in Data Services. Sync Manager has acknowledged synchronizing the object and mapped its NG ID to a QB ID in QuickBooks. Equivalent to StateCode 1 (for object created in QuickBooks).
Message code 70 seems to be ok base on its description, but it wasn't listed in the documentation.
In Quickbooks Destop, by default only the current Fiscal year transactions are displayed. Could you try changing the Date filter to "All", to see if the Sales Order made it ?
So your Request is succeeding but you are not seeing it in QuicKBooks after sync is run.
Check the sync status of the object, or you can see all the sync activity by calling these APIS
http://docs.developer.intuit.com/0025_Intuit_Anywhere/0050_Data_Services/v2/0500_QuickBooks_Windows/0600_Object_Reference/SyncActivity
http://docs.developer.intuit.com/0025_Intuit_Anywhere/0050_Data_Services/v2/0500_QuickBooks_Windows/0600_Object_Reference/SyncStatus
Even though your request succeeded, before it can by synced to QuickBooks it must pass the business rules to be created/updated on the desktop.
If your object encountered an error (lets say it was a duplicate) then you can add an errored object filter on your query to query for it as well.
regards
Jarred

PHP: Using randomly generated and integrating a retweet/share button

I am trying to create a randomly generated phrase that can easily be shared amongst social media websites, specifically twitter. I am using the following PHP code to generate a random phrase.
This code looks in 'responses.txt' for a line with a phrase and I can call that line.
<!-- HEADER -->
<?php
$randomThings = file('**responses.txt**', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
?>
<!-- CALL SCRIPT -->
<?php
echo $randomThings[mt_rand(0,count($randomThings)-1)];
?>
How would I be able to have, for example, retweet button next to this generated line that retweets the phrase with a predetermined #hatchtag (via #[websitename]).
I'm more interested in the twitter aspect, but other social media websites could help other people.
The re-tweet intent itself has problems right now. It's been filed as a bug since November so I don't think you'll want to use the re-tweet functionality from an external website. You can simulate a re-tweet with a regular tweet intent and pre-filling in the text, (which sounds like what you actually want to do). With the tweet intent you send a HTTP request to https://twitter.com/intent/tweet. You could then include the text parameter to pre-fill the text when the HTTP request is sent, or the link is clicked.
Using your example it would look something like this:
<!-- HEADER -->
<?php
$randomThings = file('**responses.txt**', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
?>
<!-- CALL SCRIPT -->
<?php
$newThings = $randomThings[mt_rand(0,count($randomThings)-1)]; //must evaluate to a string
echo $newThings;
echo 'Link text';
?>
this would be an unstyled link instead of a "button" but you can adapt it to be a button using standard HTML/CSS styling.
ref: https://dev.twitter.com/docs/intents

Resources