Category : PHP

PPTwo Lines Client-Side JavaScript to Server-Side PHP

In : PHP, Posted by on Mar.03, 2009

It is a very useful helper function for PHP and Javascript.

http://phpolait.sourceforge.net/doc/index.html

PHP-O-Lait version 0.5.1 is released, with a bug fix that caused the jsolait.js JavaScript library not to be included correctly in certain circumstances. Many thanks to Olaf Bottek for locating the bug and assisting in correcting it. A few documentation changes have also been made, including an example of using PHP-O-Lait for asynchronous communication: thanks to Keith Powell for the idea.

Tags :


setting the user agent in php curl

In : PHP, Posted by on Sep.09, 2008

I am trying to write a spider to scraoe Google result. Google returns different content for differnet user agent. Here is how to setup the user agent in curl.

$url=’http://www.google.com/search?hl=en&q=’.$keyword.’&start=10′;
$ch = curl_init($url);
$useragent=”Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1″;
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);

Tags : ,