I know there's a Rest API to check the Twitter rate limit.
To summarize policy: 150 for an IP, and 150 per non-whitelisted account except for searches (which are IP only).
However, my app is using Twython, authenticated, but the limit seems to decrease for both my accounts as I use it. Example:
No authentication:
$ wget http://api.twitter.com/1/account/rate_limit_status.xml -O -
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<hourly-limit type="integer">150</hourly-limit>
<reset-time-in-seconds type="integer">1266968961</reset-time-in-seconds>
<reset-time type="datetime">2010-02-23T23:49:21+00:00</reset-time>
<remaining-hits type="integer">134</remaining-hits>
</hash>
Authentication with account #1:
$ wget --user b... --password=youwish http://api.twitter.com/1/account/rate_limit_status.xml -O -
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<reset-time-in-seconds type="integer">1266968961</reset-time-in-seconds>
<reset-time type="datetime">2010-02-23T23:49:21+00:00</reset-time>
<remaining-hits type="integer">134</remaining-hits>
<hourly-limit type="integer">150</hourly-limit>
</hash>
Authentication with account #2:
$ wget --user d... --password=youwish http://api.twitter.com/1/account/rate_limit_status.xml -O -
<?xml version="1.0" encoding="UTF-8"?>
<hash>
<reset-time type="datetime">2010-02-23T23:49:21+00:00</reset-time>
<remaining-hits type="integer">134</remaining-hits>
<hourly-limit type="integer">150</hourly-limit>
<reset-time-in-seconds type="integer">1266968961</reset-time-in-seconds>
</hash>
You see how both accounts seem to have exactly the same rate limit info (134/150)? I only used one account in my app, so why do both accounts show decrease?
You need to set the ClientName property as being different for each call. I cut-and-pasted one of Scott Hanselmann's examples on Twitter and because the ClientName was set to TweetSandwich I was instantly given a 20,000 rate limit - so I reckon that Twitter uses the ClientName property to allocate rates rather than the authenticated user, unless the ClientName is blank when it defaults to something like IP address.
Related
I have an app that makes a outbound call to user A.
User A answers and either says "foo" or "bar"
If User A says "foo" -> c.calls(callSid).update(status="complete")
If User A says "bar" -> twilio.update('press the number 2')
How can I implement this?
I'm using the Python helper library and have tried this.
call = c.calls(callSid).update(twiml="<Play digits='2'/>")
But the app errors out.
In your outbound call use TwiML to ask the user to say "foo" or "bar" and then supply a webhook which can be called to process the response, i.e.:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather input="speech" timeout="5" action="<your webhook>">
<Say>Please say foo or bar.</Say>
</Gather>
</Response>
Twilio will do a POST to the specified webhook in action and the user answer will be stored in SpeechResult along with a confidence score in Confidence. You can then continue with your business logic as you outlined.
For more information on Gather have a look at the TwiML documentation.
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>
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.
Edit: Google has confirmed this is a bug in the client libraries: https://github.com/googleads/googleads-java-lib/issues/20
I am trying to add a Proximity targeting criterion to a campaign using the AdWords API. I am using the JAX-WS version of the API (because I need it to run on App Engine). I am able to add Proximity criteria with the AXIS version of the API, so I'm wondering if there is a bug in the API.
This is the code I'm using to add the Proximity criterion:
// Get the CampaignService.
CampaignCriterionServiceInterface campaignCriterionService =
adWordsServices.get(session, CampaignCriterionServiceInterface.class);
Proximity proximity = new Proximity();
GeoPoint geoPoint = new GeoPoint();
geoPoint.setLatitudeInMicroDegrees(43633941);
geoPoint.setLongitudeInMicroDegrees(-79398718);
proximity.setGeoPoint(geoPoint);
proximity.setRadiusDistanceUnits(ProximityDistanceUnits.KILOMETERS);
proximity.setRadiusInUnits(10.0);
List<CampaignCriterionOperation> operations = new ArrayList<CampaignCriterionOperation>();
for (Criterion criterion : new Criterion[] { proximity }) {
CampaignCriterionOperation operation = new CampaignCriterionOperation();
CampaignCriterion campaignCriterion = new CampaignCriterion();
campaignCriterion.setCampaignId(campaignId);
campaignCriterion.setCriterion(criterion);
operation.setOperand(campaignCriterion);
operation.setOperator(Operator.ADD);
operations.add(operation);
}
CampaignCriterionReturnValue result =
campaignCriterionService.mutate(operations);
// Display campaigns.
for (CampaignCriterion campaignCriterion : result.getValue()) {
System.out.printf("Campaign criterion with campaign id '%s', criterion id '%s', "
+ "and type '%s' was added.\n", campaignCriterion.getCampaignId(), campaignCriterion
.getCriterion().getId(), campaignCriterion.getCriterion().getCriterionType());
}
This is basically the code from https://github.com/googleads/googleads-java-lib/blob/master/examples/adwords_axis/src/main/java/adwords/axis/v201402/targeting/AddCampaignTargetingCriteria.java where criteria have been replaced by a Proximity criterion and with classes from com.google.api.ads.adwords.axis.* replaced by their com.google.api.ads.adwords.jaxws.* equivalents.
When run (with the appropriate information ads.properties), I get the following error:
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201402">
<requestId>0004fd8ef85c5a600aec338ad0007a98</requestId>
<serviceName>CampaignCriterionService</serviceName>
<methodName>mutate</methodName>
<operations>1</operations>
<responseTime>363</responseTime>
</ResponseHeader>
</soap:Header>
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>[CampaignCriterionError.CONCRETE_TYPE_REQUIRED # operations[0].operand.criterion]</faultstring>
<detail>
<ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201402">
<message>[CampaignCriterionError.CONCRETE_TYPE_REQUIRED # operations[0].operand.criterion]</message>
<ApplicationException.Type>ApiException</ApplicationException.Type>
<errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CampaignCriterionError">
<fieldPath>operations[0].operand.criterion</fieldPath>
<trigger/>
<errorString>CampaignCriterionError.CONCRETE_TYPE_REQUIRED</errorString>
<ApiError.Type>CampaignCriterionError</ApiError.Type>
<reason>CONCRETE_TYPE_REQUIRED</reason>
</errors>
</ApiExceptionFault>
</detail>
</soap:Fault>
</soap:Body> </soap:Envelope>
I suspect that something is going wrong when composing the xml that is sent to AdWords, because the outgoing request looks like this:
<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<RequestHeader xmlns="https://adwords.google.com/api/adwords/cm/v201402">
<userAgent>Test (AwApi-Java, AdWords-AppEngine/1.28.0, Common-Java/1.28.0, JAX-WS/Unknown, Java/1.7.0_45, maven)</userAgent>
<developerToken>REMOVEDFORSAFETYREASONS</developerToken>
<clientCustomerId>XYZ-XYZ-XYYZ</clientCustomerId>
</RequestHeader>
</S:Header>
<S:Body>
<mutate xmlns="https://adwords.google.com/api/adwords/cm/v201402" xmlns:ns2="https://adwords.google.com/api/adwords/video/v201402">
<operations>
<operator>ADD</operator>
<operand>
<campaignId>185385127</campaignId>
<criterion/>
</operand>
</operations>
</mutate>
</S:Body>
</S:Envelope>
Notice that the criterion tag is completely empty.
Running the same code, but with the AXIS version of the API works and produces the following outgoing xml:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:RequestHeader xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201402" soapenv:mustUnderstand="0">
<ns1:clientCustomerId>XYZ-XYZ-XYYZ</ns1:clientCustomerId>
<ns1:developerToken>REMOVEDFORSAFETY</ns1:developerToken>
<ns1:userAgent>Test (AwApi-Java, AdWords-Axis/1.28.0, Common-Java/1.28.0, Axis/1.4, Java/1.7.0_45, jars)</ns1:userAgent>
<ns1:validateOnly>false</ns1:validateOnly>
<ns1:partialFailure>false</ns1:partialFailure>
</ns1:RequestHeader>
</soapenv:Header>
<soapenv:Body>
<mutate xmlns="https://adwords.google.com/api/adwords/cm/v201402">
<operations>
<operator>ADD</operator>
<operand>
<campaignId>185385127</campaignId>
<criterion xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201402" xsi:type="ns2:Proximity">
<ns2:geoPoint>
<ns2:latitudeInMicroDegrees>43633941</ns2:latitudeInMicroDegrees>
<ns2:longitudeInMicroDegrees>-79398718</ns2:longitudeInMicroDegrees>
</ns2:geoPoint>
<ns2:radiusDistanceUnits>KILOMETERS</ns2:radiusDistanceUnits>
<ns2:radiusInUnits>10.0</ns2:radiusInUnits>
</criterion>
</operand>
</operations>
</mutate>
</soapenv:Body>
</soapenv:Envelope>
Notice that in the latter case, the criterion includes the geolocation and radius as one would expect.
Other types of criteria, like Location and Language work fine both in the AXIS and JAX-WS versions.
Has anyone run into this issue before? Any suggestions what could be wrong?
This was fixed in the v201409 version (release 1.34.0) of the AdWords API. Upgrading to that version fixed the issue for me.
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.