How to get information from console - javascript

I am developing an app using Java and Javascript and I have an email service that the user can send an automatic email to me if an error occurs with the application. I have it sending a blank email to me at the moment but I would like it to get the error message from the console and paste it into the email. I have to code to add it to the email but how do I get the information from the console?
EDIT:
2012-05-03 10:20:46,449 [mobileapp] DEBUG Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
2012-05-03 10:20:46,449 [mobileapp] WARN Request method 'GET' not supported
2012-05-03 10:20:46,449 [mobileapp] DEBUG Null ModelAndView returned to DispatcherServlet with name 'mvc-dispatcher': assuming HandlerAdapter completed request handling
2012-05-03 10:20:46,449 [mobileapp] TRACE Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade#741848

If you're using JavaScript, there is no "real" console. Instead install a plug-in that provides this for you - e.g. FireBug (for Firefox) or just use Chrome. That has worked for me, when you do a console.log("whatever") it should be shown there.
Good luck!

Related

The difference of the responses between axios and browser in Foursquare Places API for Venue Search

While I opened the following Foursqaure API request in the browser,
https://api.foursquare.com/v2/venues/search?near=tokyo&client_id=LBPXTL2OS0SAYRDFXR3AB0JDZSCQTFHQFTVTI4YATZ0HDFFX&client_secret=0EUYB2ZK4NEPZVFD4JAXFFCVXNW5Q1GSTILY45402QFSPFSF&v=20180323&limit=1&categoryId=4bf58dd8d48988d181941735
I got a venue with checkinsCount = 26788. But when I send a GET request for the same URL through axios like how I have done in the following codesandbox, I get a different response and the venue's checkinsCount = 0.
https://codesandbox.io/s/stoic-morning-8x2xs?file=/src/App.js
Could anyone tell me an explanation why there is a response difference?
So after some research I've found that article that says that check in data is no longer available through api.
I was quite confused though why it is visible in my Chrome, so I've tested other environments like terminal, Firefox, Safari, and basically everywhere checkinsCount was zero. But I was not logged in foursquare developer portal in those environments so I've guessed they probably check your cookies or something.
And that's seems exactly what they are doing, they have oauth_token cookie if you logged into developer portal, and if you have valid cookie then you will get some bonus data for some reason. If you have invalid cookie there will be an error in response. And if you don't have this cookie then some of the data, like checkinsCount will be unavailable
That's why #JeffUk got 0 from the first time - he was not logged in the console.

Authentication Credentials with the SendPulse API for Node

I'm using the SendPulse client library written in node for smtp. Here's a snippet from their example.js:
var API_USER_ID="USER_ID"
var API_SECRET="USER_SECRET"
var TOKEN_STORAGE="/tmp/"
sendpulse.init(API_USER_ID,API_SECRET,TOKEN_STORAGE);
I've tried using my email address that I've created the account with, and the password they gave me on the SMTP settings page, for user_id and user_secret, respectively. When I run the code, I get this error message:
{ error: 'invalid_request', error_description: 'The request is
missing a required parameter, includes an invalid parameter value,
includes a parameter more than once, or is otherwise malformed. Check
the "access token" parameter.', message: 'The request is missing a
required parameter, includes an invalid parameter value, includes a
parameter more than once, or is otherwise malformed. Check the "access
token" parameter.', error_code: 1 }
However, it doesn't seem to matter what you do, you'll always get that error message. You can run sendpulse.ini(); and still get that message.
My question is, what are the proper credentials to use the SendPulse node library? The smtp settings page also gives me a public key, not sure what to do with that. I've noticed this library is a year old, is it out of date? Your help is much appreciated. I'm at the end of a very big project, this is the last hurdle.
You need to use "ID" and "Secret" from the https://login.sendpulse.com/settings/ page, go to "API" tab and enable "Activate REST API".

Getting error on Evernote listNotebooks API - Javascript / Node.Js

My web app in importing Evernote notebooks of a user to visualize them as a network.
Everything works fine with a sandbox version, but once I try to do it on the production server, when I do
noteStore.listNotebooks
I get the following err:
{ errorCode: 8,
message: 'authenticationToken',
rateLimitDuration: null }
You can see the code on https://github.com/noduslabs/infranodus/blob/evernote/routes/imports.js#L428
My developer API is activated on the main server (at least I requested it a few months ago and received a confirmation of that). My developer API username is infranodus.
ALso, the oAuthAccessToken also seems to be obtained and transmitted inside my app.
Could you please tell me why this error pops up and how can I extract the notebook list – both private and public ones for the user?
Thank you for your help!
How did you get the token ? Is it a dev token or an oauth one ?
In both cases make sure that they were issued by the production server and not the sandbox one (i.e. you can't use a sandbox token in production environment).
If it's a prod token, I'd suggest to open a support ticket asking the Evernote team to check your credentials : https://dev.evernote.com/support/ (manage an api key)
Another suggestion : get a prod token (https://www.evernote.com/api/DeveloperToken.action) and use it instead of your oauth token. If it works then you have a problem with your API key (and you should open a support ticket as suggested above). If it does not work then there's an issue with your code.

What is the best/proper configuration? (javascript SOAP)

I need to retrieve data from a web service (via SOAP) during a nightly maintenance process on a LAMP server. This data then gets applied to a database. My research has returned many options and I think I have lost sight of the forest for the trees; partially because of the mix of client and server terms and perspectives of the articles I have read.
Initially I installed node.js and node-soap. I wrote a simple script to test functionality:
var soap = require('/usr/local/lib/node_modules/npm/node_modules/soap');
var url = "https://api.authorize.net/soap/v1/Service.asmx?WSDL";
soap.createClient(url, function(err, client)
{
if(typeof client == 'undefined')
{
console.log(err);
return;
}
console.log('created');
});
This uses a demo SOAP source and it works just fine. But when I use the actual URL I get a 5023 error:
[Error: Invalid WSDL URL: https://*****.*****.com:999/SeniorSystemsWS/DataExportService.asmx?WSDL
Code: 503
Response Body: <html><body><b>Http/1.1 Service Unavailable</b></body> </html>]
Accessing this URL from a browser returns a proper WSDL definition. I am told by the provider that the 503 is due to a same-origin policy violation. Next, I researched adding CORS to node.js. This triggered my stepping back and asking the question: Am I in the right forest? I'm not sure. So, I am looking for a command-line, SOAP capable, CORS app (or equivalent) configuration. I am a web developer primarily using PHP and Javascript, so Javascript is where I turned first, but that is not a requirement. Ideas? Or, is there a solution to the current script error (the best I think I have found is using jQuery in node.js which includes CORS)
Most likely, this error belongs to your website server.
Please go through this link, it might be helpful.
http://pcsupport.about.com/od/findbyerrormessage/a/503error.htm
Also you can open your wsdl in web browser, search for soap:address location tag under services. And figure out correct url, you are trying to invoke from your script. Directly access this url in browser and see what are you getting.
I think I have a better approach to the task. I found over the weekend that PHP has a full SOAP client. I wrote the same basic login script in PHP and it runs just fine. I get a valid authentication code in the response to loginExt (which is required in further requests), so it looks like things are working. I will comment here after verifying that I can actually use the web service.

Google API Authorisation with JavaScript

Hi I hope someone can help with this because it's driving me crazy right now.
I am trying to replicate this Google API authorisation example https://code.google.com/p/google-api-javascript-client/source/browse/samples/authSample.html on my own web server http://james-gilmore.co.uk/test.html
I have duplicated the code but replaced the clientID and API key with the keys set up in the google api console and I have turned the Google+ api service on in the 'Services' section.
I have the following set up under 'Client ID for web applications'
Redirect URIs: http://james-gilmore.co.uk/oauth2callback
JavaScript origins: http://james-gilmore.co.uk
And I also have the following set up under 'Simple API Access'
Referers: .james-gilmore.co.uk/.
When I run the http://james-gilmore.co.uk/test.html script I can authorise my access but I can see a JS error generated in the console:
'Uncaught TypeError: Cannot read property 'url' of undefined'
Does anyone know what I could be doing incorrectly? I think it may have something to do with the setup of my client ID's and allowed Referers because when I run the following example https://code.google.com/apis/console/?api=plus it works fine
The OAuth authentication appears to be working, but I see an error Access Not Configured being returned from an AJAX call.
Set up your referers as james-gilmore.co.uk/* (with the trailing wildcard, so that it will allow anything starting with your domain name).

Categories

Resources