Live comments Update without realoading page in PHP posible? - php

i was viewing this video and i really want to develop this is PHP with no AJAX, do you how to start? where can i find some examples codes? Thanks.

Live "streaming" without AJAX could be done in PHP using ob_flush/flush, ergo output buffering. But that's usually pretty dirty and unwanted. However, what you see in that video is only possible with Javascript/"AJAX" (or Flash and similar plugins).

Hello, i was viewing this video and i
really want to develop this is PHP
with no AJAX, do you how to start?
There is no way to start as that functionality requires Ajax. Your hole is a square, why not use the square peg (Ajax).

Related

Language for web scraping JAVASCRIPT content

I think topic ask the question, I usually use PHP for parse/ web scraping, but I have really bad time scraping javascript most cases I cant do it
ex: Parse a div that appears when a javascript its executed.
I readed about RUBY, that have a parser library for javascript, so question is w is the languaje for program a web scraping that will effective scrap javascript generated content ?? Its here a library for PHP like the one for ruby for parse javascript content ?
There are a handful of strategies for this. Depending on your needs, consider pro grammatically instantiating a browser instance that you can hook into and read the page from.
The idea is, let the browser do the work, as the page is made for a browser and not your bot. You can then tap in and scrape away using a browser plugin that feeds data to your primary application running things.
This may be way overkill for what you need though. I'll leave it up to you to decide.
You should look at some GUI-less/headless browsers. There is some written for Java. I didn't find one for PHP.
Look at :
HTMLUnit
Golf
You can try using something like Selenium, which allows you to automate browser tasks.
On the other hand, you can go into details on what happens when the js code is executed. For example, if the js code is requesting something from the server by POSTing some data, you could emulate that in the regular fashion.
You should look at PhantomJS and CasperJS (headless browsers).
In the ruby world the gem for running Phantomjs would be poltergeist
There is another article about some of the options you have in ruby here too (however they are not all js capable)

PHP/Flash advice

Looking to start a project that would require me to use Flash or Flex (I have not worked with either of these yet, yikes!!!). Flash would be the front end user interface that needs to display items pulled from a MySQL Database (I was thinking ajax via jQuery but open to suggestions). My question is, What would be the best approach for something like this?
High level
Flash calls to display image through ajax/php from Db
I don't know how to code the Flash part, any tutorials that kinda sound like what I'm doing? suggestions? thoughts? other ideas?
Side Note: The database table will contain text that describes the image being passed to flash, so I would like to display both the text and image.
Thanks for any advice/help,
--Phill
I'd recommend you try AMFPHP or ZendAMF. Both of these use AMF3 (which requires you to use Actionscript 3/FlashCS3+), and it is one of the quickest ways to get data into Flash.
You could also use php to generate an xml file and just request that url in Flash to load up the XML. You can also use ajax like you said, but it's probably going to be the slowest method open to you, unless you're working with very small data sets.
Regardless of the method you choose, I'd suggest you use Actionscript 3. It's much faster and if you use XML, it'll be a life saver.
Here's a tutorial about setting up flash to work with PHP & MySQL:
link

Is there a way to automatically take a screenshot of a website through a URL?

I am trying to find a PHP script (or a script in a different language) that after passing a URL, it takes a screenshot of the website for that URL. So for example if I pass stackoverflow.com, it should take a screen shot of the website (in this case the homepage), keep it on the server, and provide a link to that pic.
Is there an easy way to do that?
I know it is possible because that's how they take thumbnails for websites in Alexa for example.
If you need more explanation of what I mean please just post a comment and I will explain more.
Thank you :)
Start a Browser (like system("firefox [url]")), run a screengrabber for that window and save the image somewhere.
Since the output is always depending on the render engine used it is not possible by using php alone.
Other option would be to embed a rendering engine (Gecko or similar) into your php script.
You can use browsershots.org service or litmusapp.com.
Both of these will generate screenshot of a page. You can then download the screenshot and use it in a way you need to.
Something like Litmus?
Browsershots normally has their backend source code available, but as of this answer, it appears to be offline at the moment. There is an outdated mirror on Github which you can look at.

facebook status bar

Anyone know a good tutorial of how to make the status bar found in the new facebook? the one on the bottom. looks really cool
i was thinking it was written in either ajax or jquery. but not sure.
Here are some useful links/plugins that might help you:
Positioning the footer
Enable drag/drop of things (like applications)
Tooltip (when hover)
And for the interaction with the server (for new events etc.) you might use the AJAX functionality in jQuery:
In order to have it always be in the bottom, that is more of CSS than javascript.
I think you would get better answers if you were more specific. For example, I would want the answer to revolve around as to how the chatroom works on facebook. Is the javascript request being sent every second to check for new messages? or is there another protocol being used in order to have instant messages?
It's not clear what your are looking for: bar's design or it's functionality. If your are speaking about design you should look into css positioning (absolute). If it's about functionality i suppose that there is some kind of ajax javascript which checks every x seconds if there is change of state, and if there is go deeper and find out what to load.
Why not just download the Facebook source code and take a look at how they do it? They open sourced a lot of the stuff they use/created/enhanced.
Soh Tanaka just put out a great step-by-step tutorial on how to re-create the Facebook Status Bar:
Here's another good starting point: http://www.ben-griffiths.com/project/jquery-position-footer/. If I remember correctly it works in FF & IE & Safari
I looked through the jQuery plugins, and Googled the topic for you. All I could find was this which isn't exactly what you want, but it is a good place to start. With some style changes, and a little tweaking it could easily look exactly like the Facebook bar.
Not sure that this is the type of answer you were looking for, but i've been looking for the same thing and this code seems to at least show how it's done.

Screen Grab with PHP and/or Javascript?

Just wondering if it's possible to screen grab a page you are viewing with a PHP script or javascript? For example, load up a page in an iframe and then save that view as a JPEG?
I'm sure it's possible somehow, but are there any known implementations/libraries that help out?
Nope, sorry, it is impossible with Javascript and definitely impossible with a server-side language like PHP. (Edit: I mean it's impossible to take a screenshot of the user's view of the page.)
It depends on what you want to do this for, but you might want to find a script or program that runs server-side and renders the webpage there. But if you really want to take the screenshot of the user's view of the page, it's pretty much impossible.
http://html2canvas.hertzen.com/ might do the trick.
There is a python tool called Webkit2png, hope it helps. But in PHP, i don't believe its possible
You can't do it in JS but you could do something similiar server side if you know the url of the page you want to convert to an image.
Tools like khtml2png could be called from php to render the page.
Possible with the GD2 extension and some knowledge of the internals you are capturing - read here for an example.
Thanks for the help guys. I did find this interesting resource:
http://www.zubrag.com/scripts/website-thumbnail-generator.php
It's not PHP specific by any means, just an example of running an EXE script that is called by PHP. Needs a windows server I believe though.

Categories