?
Solved

How to capture and get javascript output using PHP ?

Posted on 2011-04-23
3
Medium Priority
?
491 Views
Last Modified: 2012-05-11
Hi,

I would like to request an assistant.

I have the following javascript loaded in "livechat.php" :

<script language="javascript" src="https://domain.com/visitor/index.php?_m=livesupport&_a=htmlcode&departmentid=0&fullname=&email="></script>

The script will display/load the following image when the user using it is online :

https://domain.com/themes/client_default/staffonline.gif

When the user using it is not online, it will display the following :

https://domain.com/themes/client_default/staffoffline.gif

The problem, is that this images does not shows in browser VIEW SOURCE, it just being loaded on the fly.

I would like anybody can assist in using CURL or anything else in php to detect/capture this behaviour :

Eg:


if (staffonline.gif == is found in livechat.php)
{ do something }

if (staffoffline.gif == is found in livechat.php)
{ do something else}


Appreciates anybody assistant.


Thank you.
0
Comment
Question by:smksa
  • 2
3 Comments
 
LVL 6

Expert Comment

by:_iskywalker_
ID: 35455263
I fear you cannot do it, since the javascript is on the client side and the php is in the server side.
You can although get some infos if the javascript save it as cookie and you recover with the php from it.
the php normally generate the web page on the server, sends to the client, and then the client executes the javascript. so there is no interface to interact between javascript and php directly, only by cookies or by post and get methods. the javascript could also change urls to send a variable and telling the php script that the user is offline the next time the php generates a webpage
0
 
LVL 2

Author Comment

by:smksa
ID: 35455331
But, i believe if using CURL , the PHP will crawl to the website as if it is a client right ? Thus, can it detect the images ?
0
 
LVL 6

Accepted Solution

by:
_iskywalker_ earned 2000 total points
ID: 35505589
If a user is online it authentificated with a server and saved it as a cookie info.Or how the user connects with the server? Another way would be use ajax. Load the page till you get the javascriupt thing, and then use an ajax request with the right parameters to get the rest of the webpage
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question