How can I run a script while http request is sent? - php

I am building a website that will call a third-party web service. This web service is sometimes slow, however, and clients visiting the webpage aren't familiar with the loader on the browser tab. This results to them clicking, again and again, the search button that calls the web service and it gets never completely sent.
I was thinking of making an overlay page with a CSS loader right in the middle of the page so that it's more than obvious that something's loading and force them to wait. I tried researching how to run a script while an HTTP request is being sent, but didn't get any answers. Any thoughts?
Thanks in advance for your time.
The WiP website is https://b2b.a-link.gr/ (unfortunately a client username and password is required to access it) and the web service website is https://www.soft1.eu/. The web service has a database through which I pull out data to make searches on my website.

Related

How to use Node.js, Express, and Socket.io in a PHP file being served by Apache?

I am working on a project that was written in PHP and being served on an Apache server. I have been asked to integrate Socket.io live chat functionality into a page that was written in PHP and served by Apache. To do this, I've been writing a Node.js application with Express. But I can't figure out a way to integrate my Express app into the PHP page.
I have googled this for several hours and found many tutorials about running Node.js and Apache on the same server but different ports, but as I understand it, that strategy would limit me to serving different pages or different files. What I need is to be able to use the Socket.io livechat function on the PHP page.
I thought maybe I could use an iframe integrated into the PHP page to display the livechat window itself, but I also need to display new chat request notifications on the PHP page and give the user the ability to click different tabs to switch between chat windows. I thought I could probably have the tab clicks handled by writing a REST API on the Node.js end and letting the PHP page make calls to that. But I'm not sure how I would have the PHP page display new chat request notifications if I can't have Express and Apache handling the same page.
So my question is basically how to:
1) Configure things so one PHP page can be accessed and manipulated by both the PHP side and the Node.js/Express side of things, or
2) Route Socket.io events from the Node.js/Express side into the PHP side so that they can be handled on that end.
Context: I know minimal, minimal PHP--that's being handled by my colleagues, and my role is the JavaScript and Node.js stuff--so please keep that in mind.

PHP open a running app in multiple tabs in same browser

I have a php application in which I scrape a website and get all of the links present in the site. While I am running the scraper in a tab of a browser and open the app in the other tab of the same browser, it keeps loading until the other tab processing(running scraper) is complete.
I have tried using ajax in this case i.e. I send the request through ajax post to find the links, but it is not effecting.
Any kind of help and guidance will be appreciated.
That is probably caused by the session lock. If your multiple connections (tabs) require the same session, you can't.
If they could be independent, then you would have to pass a session id in the URL to identify which tab is communicating with the server.
Note that the web server may also have restrictions configured on the number of simultaneous sessions from the same IP.

Remote control Slideshow via SOAP webservice

I want to remote control my slideshow (jQuery plugin Cycle2) that displays pictures that are selected by the user and requested from a server via AJAX. The server side script returns the whole HTML output for the pictures and additionally a navigation bar for stopping/pausing the slideshow.
Now, what I want is to have these navigating functions as a small web app on a smartphone to remote control the slideshow run on the server. I thought about a SOAP based webservice for the interaction between smartphone and server. The problem is how do I write functions that execute actions on my slideshow? Is it possible to trigger a button of a PHP script from within a function of another one?
I hope the problem became clear. I'm not asking for code, I simply don't know how to proceed here.
Ok, it just came to my mind. I can execute AJAX calls on the slideshow from a function of the webservice. Then however, I have to deal with these problems: Ways to circumvent the same-origin policy
Would that be a good way to do this?

How to tackle IP blocks of an external website with proxies?

I am working on a scraping project to extract web data from a website. I have made a script to go through URLs and parse HTML contents and get the structured content into my database.The script was working fine,but recently the script got stuck and on investigation it was found that the target site is blocking our IP.
I am using PHP / CURL for this project,now I am getting a 403 error - Access Forbidden, error on a web request.
This has affected the working of my script,no pages could be retrieved from web request,every time I am getting an access restricting error.
I know there are lot of scraping etiquette's to be followed.Since we can't foresee how they had implemented the security features,I was confused on normalizing the web request calls.
I'm working on an amazon AWZ instance with an elastic IP,hence I am confused on when/whether they would lift the ban on my IP.
I have heard of rotating proxy methods to be used with scraping,such that the target server won't block you often.But I'm not sure about it's implementation.
Any help would be highly appreciated.I could provide any additional information if necessary.
sign in to the site to get an API id.
if you send a request to the site with API id and URL. it will send a request to the required URL with a random API and return a response.
just sign in and try it
signup

php cURL or file_get_content affect on google analytics

Im wondering what affect loading an external page with php has on a sites analytics. If php is loading an external page, and not an actual browser, will the javascript that reports back to google analytics register the page load as a hit?
Any JavaScript within the fetched page will not be run and therefore have no effect on analytics. The reason for this is that the fetched HTML page is never parsed in an actual browser, therefore, no JavaScript is executed.
Curl will not automatically download JavaScript files the HTML refers to. So unless you explicitly download the Google Analytics JavaScript file, Google won't detect the Curl hit.
Google offers a non-JavaScript method of tracking hits. It's intended for mobile sites, but may be repurposable for your needs.
You're misunderstanding how curl/file_get_contents work. They're executed on the server, not on the client browser. As far as Google and any regular user is concerned, they'll see the output of those calls, not the calls themselves.
e.g.
client requests page from server A
server A requests page from server B
server B replies with page data to server A
server A accepts page data from server B
server A sends page data to client
Assuming that all the requests work properly and don't issue any warnings/errors and there's no network glitches between server A and server B, then there is absolutely no way for the client to see exactly what server A's doing. It could be sending a local file. It could be executing a local script and send its output. It could be offshoring the request to a server in India which does the hard work and then simply claims the credit for it, etc...
Now, you CAN get the client to talk to server B directly. You could have server A spit out an HTML page that contains an iframe, image tag, script tag, css file, etc... that points to server B. But that's no longer transparent to the client - you're explicitly telling the client "hey, go over there for this content".

Categories