Getting ping response server information in javascript (browser + chrome aPP) - javascript

I am trying to ping some web server and want to know information of replying web server.If some proxy is in between then it should return information of that web proxy.For example ping server is- http://www.google.com and consider following two scenario
1:-In normal scenario it should give information http://www.google.com or its ip- address
2:-In case of airport ie some proxy involved it should return airport.com or its ip instead of http://www.google.com
For this i have tried Ajax call but not able to figure out which one is returning response because in header none field of this type information present.By doing Ajax call i am able to figure out whether http://www.google.com is alive or dead.
Please suggest some alternative for browser and chrome app.

Related

SPA: Access Instagram authentication code directly in app

I load user profile informations from instagram by the basic api in a local test app.
So this actually works like written in the documentations.
I used Postman to get along the authentication and token stuff.
The order to access the graph api, to query media fields would be like:
Get access code (from authentication window redirect url)
Get access token (from acces_token endpoint)
Get media data (from graph api by access_token)
I´m using UI5 js framework with UI5 Tooling.
I get a response with data in step 3 from ajax call, but first i have to execute step 1 and step 2 manually.
But i want to do all this authentication-mechanism directly in my app. Including opening this authentication window and acessing the code from the redirect url.
When i do an ajax call in step 1, i get an CORS error of course, because step 1 doesnt respond with the corresponding CORS header (like step 3 does).
Well, anyways i most likely could handle this by a proxy, but whats about the production environment? I dont get how this approach should ever work in a real app. Even when the CORS problems are handled by aproxy in dev environment, it should be still there when a real user uses the app.
So the question is: How can i access or implement this authentication window (on a diffrent origin) in my app? I have seen other apps doing this permission window, but i have no clue how to implement it in a web app.
By clicking "Allow" you get redirected to he redirect_url with the access code
How can i get the access code directly in my app, avoiding CORS in production
I don't have a definite answer, but regarding your CORS issue: It seems like instagram added a CORS policy somewhere last year (see this other question on SO). This means that you would indeed have to build a proxy.
Basically you need something that accepts all the endpoints that the original API accepts, forwards them to instagram, reads the response, and returns the response to the client (aka browser). But your proxy will then not add the CORS headers. Or even better, you add your own CORS headers (assuming your proxy and your app will run on the same server) and no one else will be able to use your proxy from their web app.
Unfortunately I don't know about this authentication window. Maybe this is just a fancy way to hide that they are running a proxy behind the scenes as well? You should be able to see in the network tab where the insta data is coming from after you login. I would guess not directly from their graph API.

ERR_CERT_COMMON_NAME_INVALID from jQuery Using Reverse Proxy

I am having an issue with 'ERR_CERT_COMMON_NAME_INVALID' when making a request from a website.
First of all, am really a bit of a novice when it comes to setting up and using certs... so this is probably something stupid that I have ether done or not done!
I have a ssl certificate www.my-dummy-url.abc and api.my-dummy-url.abc (obviously my-dummy-url is for example only). Where api.my-dummy-url.abc is the certificate Subject Alternative Name and www.my-dummy-url.abc is the certificate Subject.
The Apache Web sever, is hosted at www.my-dummy-url.abc, whilst a reverse proxy points 'api.my-dummy-url.abc to a Raspberry Pi running a little node.js API endpoint (/weather).
I have set node.js up to use express: https.createServer(ssl_options, ..., where ssl_options is my cert.pem and key.pem. CORS is enabled (app.use(cors());) and 'Access-Control-Allow-Origin', '*' is present in the response.
The Website (apart from the API call) renders fine at https://www.my-dummy-url.abc (Chrome).
The API, (https://api.my-dummy-url.abc/weather) if requested within the address bar of a Chrome browser or through Postman receives the correct JSON response.
However, from my website as a jQuery $.get function I get the following error:
GET https://api.my-dummy-url.abc/weather net::ERR_CERT_COMMON_NAME_INVALID
Any ideas, helpers, pointer or solutions will be gratefully received...
As an addition, if I use Edge rather then Chrome, it works...!
Kind Regards,
Harold Clements
This issue was that Chrome was caching the certificate somehow. After shutting down and coming back to it the next day, it was working fine.

How can I see webrequests Facebook sends me

I am wondering how I can see exactly what webrequests I am receiving from Facebook?
Lets say that we are on Facebook event and I want to invite all my 1000 friends.
I start clicking all my friends one by one and at some point Facebook sets a limit of 498 and then I continue to do all the clicks until I reach 498 and then it says you cant invite anyone else.
Facebook to do this at some point sends back an ajax.php page as a packet and sets this limit. This ajax php page i'm trying to find somehow.
I've tried some ajax jQuery capture Chrome extensions but I dont quite understand them much.
Do you have any idea of how I can track any ajax php request from Facebook to my browser to set this limit?
I am using Chrome Extension Live HTTP Headers
and this shows me anything that Facebook webrequest is "POST" in my browser.
But i dont think its actually all of them.
Because its only loading the photos of the chat
and some thread updates.
Here is a video of what limitation is showing in my frame of friends invite in facebook.
Youtube Video Here.
Press F12 and find the network requests section of your browser's dev tools.
http://www.devtoolsecrets.com/secret/general-finding-the-development-tools.html
I think you are misunderstanding the process. Web servers don't send requests to web browsers. They only respond to requests sent from the web browser.
When you click to invite friends you are sending an ajax request to Facebooks server. That ajax request passes the information about the event, you and your friend to a method on the server. Part of that method is to check and see if the limit on invitations has been exceeded. If not it sends your invitation and sends a response to your ajax request showing this person was invited. However if the limit has been reached the invitation is not sent and the response comes back from your ajax request stating that the limit has been exceeded.
If you know what your doing, you use Chrome or Firefox developers tools to debug javascript and follow the ajax request to the server and the response from the server. But this is difficult with the minified javascript. There are tools to deminify the javascript making it easier.
However, if you're looking for a way around the invitation limit. It's not going to happen. This all occurs on the Facebook servers to which you do not have access.
Try to use Fiddler (http://www.telerik.com/fiddler). With Fiddler you can see all requests (also HTTPS requests with an intermediate certificate), modify those or simply replay requests. It's worth a try and a must have for each web developer

407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )

I have developed a website which uses Ajax POST using jQuery to a PHP server.
While it works perfectly when accessed from a web browser at home, some of my Ajax requests fail when accessed from a web browser on my day job's corporate network, and I get the following error shown by Firebug: 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ). Note that Chrome does not show the error but it is still blocked, and IE11 blocks it as well but I haven't been able to view the message using Development Tools due to an unrelated issue (Error in jquery.validate.js in MVC 4 Project with jQuery 1.9).
I have no ability to modify anything on the corporate network, nor is it my desire to do so. My desire is to modify the HTML/JavaScript/Headers which my server provides to eliminate blocking of the request so others do not experience this issue.
What can be done?
This happens when you are using a complete url address in your html or jquery posts
e.g.
action="http://www.example.com/mydir/myfile.php"
Try changing the url reference so that it doesn't include the website address
e.g.
action="/mydir/myfile.php"
This also works when posting with AJAX/jquery
e.g. the code below produces the same error
var url1="http://www.example.com/mydir/myfile.php";
$.post(url1, function(data){alert(data);});
but this code doesn't
var dir1="/mydir/myfile.php";
$.post(dir1, function(data){alert(data);});
It is important to note that when you switch from the complete urls to the directories, you have to define your directory relative to your current file directory.

Soap request to WCF web service on Azure via Javascript

I have a WCF web service hosted on Azure as a cloud service. I am trying to send a POST SOAP request from an HTML/JS web application it appears I cannot POST a SOAP envelope across domains. I have tried a variety of POST techniques with no avail. Has anybody experienced this before and/or is aware of a work around?
Any help would be appreciated.
Cheers
No, this is not possible, as per AJAX cross-domain requests cannot be made unless the server says " I'm ready to accept".
Normally, when you make a cross domain request an OPTIONS request is made to the server, to check what all methods and options are given allowed at the server. The server responds with a set of headers which says further communication can be made or not.
So, if you want to do a cross domain AJAX POST/GET, you can do it provided either of the following is possible
-> Server says "I am ready to accept" for your client request - which normally does not happen
-> Use a proxy server in your layer, to forward the request to target server, and revert back the response.
For more info, you can scroll on MDN forums or CORS facts.

Categories