Friday, December 19, 2014

Parse Website with PHP

Parse Website with PHP

Parsing website pages is always a challenge for PHP Developers. Parsing is using for retrieving images, scraping websites, crawling, error detection websites, and many other useful purposes. But PHP Simple HTML DOM Parser is a awesome or can say dream library for developer that work with both PHP and the DOM element using PHP.


You can get the Simple HTML DOM Parser from here and save file to any directory of your choice. First in a basic example we’ll include the class, and get all hyperlinks on the http://4evertutorials.blogspot.com .

<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/

// Include the parser library
include('simple_html_dom.php');

// Retrieve the DOM from a given URL
$html_dom = file_get_html('http://4evertutorials.blogspot.com/');

// scan for all hyperlinks and print
foreach ($html_dom->find('a') as $element) {
       print $element->href;
}

?>
Below are few basic uses of PHP Simple HTML DOM Parser.
<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/

// Include the parser library
include('simple_html_dom.php');

// Retrieve the DOM from a given URL
$html = file_get_html('http://4evertutorials.blogspot.com/');

// Find all anchor tags and print their HREFs
foreach($html->find('a') as $e) 
    echo $e->href;

// Retrieve all images and print their SRCs
foreach($html->find('img') as $e)
    echo $e->src;

// Find all images, print their text with the "<>" included
foreach($html->find('img') as $e)
    echo $e->outertext;

// Find all SPAN tags that have a class of "SpanClass"
foreach($html->find('span.SpanClass') as $e)
    echo $e->outertext;

// Find all TD tags with "align=center"
foreach($html->find('td[align=center]') as $e)
    echo $e->innertext;

// Extract all text from a given cell
echo $html->find('td[align="center"]', 1)->plaintext;

// Find the DIV tag with an id of "DivId"
foreach($html->find('div#DivId') as $e)
    echo $e->innertext;


?>

Thursday, October 16, 2014

Install CodeIgniter Framework


In this post we will cover how to install codeigniter framework and we will view the most common steps to install codeigniter framework. CodeIgniter is one of the most popular PHP frameworks around. It uses the Model-View-Controller Architectural design pattern and it’s considered by lots of PHP developers as one of the best framework solution for small to medium projects.

How to Install

The installation itself is such a simple process. First of all, you need to download the CodeIgniter zipped file, upload it to your server and extract it into your home directory. You can download it from https://ellislab.com/codeigniter/user-guide/installation/downloads.html.

Configuring CodeIgniter

Congratulations, now you have CodeIgniter installed on your server. Now it’s time for configuration. Open the application/config/config.php file with your preferred editor and set your base URL. If you intend to use encryption or sessions, set your encryption key. For the database configuration, open the application/config/database.php file with your preferred editor and set your database host, name, user, password and other values that you think it will help you connect to your database. You will find array variables with comments to know the role of each value.

Configuration files

By editing the two previously mentioned files, you are ready to start coding your first web application but CodeIgniter contains more files that enable more configuration and customization abilities. The configuration files can be found in the application/config/ directory. The following is a quick description of what you can do by editing some of the most commonly used configuration files:

autoload.php : specifies which systems (Packages, Libraries, Helper files, Custom config files, Language files and Models) should be loaded by default.

config.php : contains all website configuration.

constants.php : contains defined constants which are used when checking and setting modes when working with the file system.

database.php : contains the settings needed to access your database.

email.php : This file is not created by default. But you can create it and set the default values for the email class. Like: mailtype, charset, newline, protocol, smtp_host, etc.

hooks.php : lets you define “hooks” to extend CI without editing the core files.

mime.php : contains an array of mime types. It is used by the upload class to help identify allowed file type.

routes.php : lets you re-map URI requests to specific controller functions.

smileys.php
: contains an array of smileys for use with the emoticon helper.

upload.php : This file is not created by default. But you can create it and set the default values for the upload class. Like: upload_path, allowed_types, max_size, max_width, max_height, etc.

user_agents.php : contains four arrays of user agent data. It is used by the User Agent Class to help identify browser, platform, robot, and mobile device data. The array keys are used to identify the device and the array values are used to set the actual name of the item.

Monday, October 6, 2014

php To PDF

php To PDF is an API based solution. We are a web service providing you the easiest way to generate PDF files from PHP Code.

Our server does the heavy lifting and generates the PDFs for you. The generated PDF files will be returned and stored on your server in the specified directory with your specified file name, or you can set them to be created and displayed or downloaded by a user on the fly.

You do not need any special packages or permissions. It works on any server running PHP!

We have simplified our API so that you just need to download the phpToPDF.php file from your account and include it in your code. It's that simple.

Get started :: PHP to PDF generation steps
Sign up to access our API   
2  FREE!
Download and include phpToPDF.php

Sample Code

Use the phptopdf() function for creating a PDF using a URL



<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/


    require('phpToPDF.php');

    //Set Your Options -- see documentation for all options
    $pdf_options = array(
          "source_type" => 'url',
          "source" => 'http://google.com',
          "action" => 'save');

    //Code to generate PDF file from options above
    phptopdf($pdf_options);
 

?>



Alternatively, you can use the phptopdf() function to pass a varible that holds html code for your PDF.

<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/

    require('phpToPDF.php');

    //Your HTML in a variable
    $my_html="

PDF from HTML using phpToPDF

"; //Set Your Options -- we are saving the PDF as 'my_filename.pdf' to a 'my_pdfs' folder $pdf_options = array( "source_type" => 'html', "source" => $my_html, "action" => 'save', "save_directory" => 'my_pdfs', "file_name" => 'my_filename.pdf'); //Code to generate PDF file from options above phptopdf($pdf_options); ?>


[ More Examples ]

Thursday, September 4, 2014

New features in PHP 5.6

The PHP development team announced new release of PHP 5.6. The new release brings new features and lots of improvements, development team say, also as some backward incompatible changes.

Following are the most important changes in PHP 5.6 release:




Constant scalar expressions
It is now possible to provide a scalar expression involving numeric and string literals and/or constants in contexts where PHP previously expected a static value, such as constant and property declarations and default function arguments.
<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/

const ONE = 1;
const TWO = ONE * 2;

class C {
    const THREE = TWO + 1;
    const ONE_THIRD = ONE / self::THREE;
    const SENTENCE = 'The value of THREE is '.self::THREE;

    public function f($a = ONE + self::THREE) {
        return $a;
    }
}

echo (new C)->f()."\n";
echo C::SENTENCE;

//The above example will output:
/*
4
The value of THREE is 3
*/

?>
Improved syntax for variadic functions
Variadic functions can be declared through a new ... operator:

<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/
 
function f($req, $opt = null, ...$params) {
    // $params is an array containing the remaining arguments.
    printf('$req: %d; $opt: %d; number of params: %d'."\n",
           $req, $opt, count($params));
}

f(1);
f(1, 2);
f(1, 2, 3);
f(1, 2, 3, 4);
f(1, 2, 3, 4, 5);

// The above example will output:
/*
$req: 1; $opt: 0; number of params: 0
$req: 1; $opt: 2; number of params: 0
$req: 1; $opt: 2; number of params: 1
$req: 1; $opt: 2; number of params: 2
$req: 1; $opt: 2; number of params: 3
*/

?>
Argument unpacking via ... operator
Arrays and Traversable objects can be unpacked into argument lists when calling functions by using the ... operator. This is also known as the splat operator in other languages, including Ruby.

<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/

function add($a, $b, $c) {
    return $a + $b + $c;
}

$operators = [2, 3];
echo add(1, ...$operators);

// The above example will output:
/*
6
*/
?>

Exponentiation via ** operator
A right associative ** operator has been added to support exponentiation, along with a **= shorthand assignment operator.

<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/

printf("2 ** 3 ==      %d\n", 2 ** 3);
printf("2 ** 3 ** 2 == %d\n", 2 ** 3 ** 2);

$a = 2;
$a **= 3;
printf("a ==           %d\n", $a);

// The above example will output:
/*
2 ** 3 ==      8
2 ** 3 ** 2 == 512
a ==           8
*/

?>


use function and use const
The use operator has been extended to support importing functions and constants in addition to classes. This is achieved via the use function and use const constructs, respectively.


<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/ 
 
namespace Name\Space {
    const FOO = 42;
    function f() { echo __FUNCTION__."\n"; }
}

namespace {
    use const Name\Space\FOO;
    use function Name\Space\f;

    echo FOO."\n";
    f();
}

// The above example will output:
/*
42
Name\Space\f
*/


?>

Now UTF-8 is Default character encoding
default_charset is now used as the default character set for the htmlentities(), html_entity_decode() and htmlspecialchars() functions. Note that if the (now deprecated) iconv and mbstring encoding settings are set, they will take precedence over default_charset for iconv and mbstring functions, respectively.

Large file uploads 
Files larger than 2 gigabytes in size are now accepted.

GMP supports operator overloading
GMP objects now support operator overloading and casting to scalar types. This allows for more expressive code using GMP:
<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/ 
 
$a = gmp_init(42);
$b = gmp_init(17);

// Pre-5.6 code:
var_dump(gmp_add($a, $b));
var_dump(gmp_add($a, 17));
var_dump(gmp_add(42, $b));

// New code:
var_dump($a + $b);
var_dump($a + 17);
var_dump(42 + $b);

?>

Full list of all changes in PHP 5.6 can be additionally found in the here.

Wednesday, September 3, 2014

Using Google PageSpeed Insights API with php

In this post we learn how to analyze websites using google pagespeed insights api with PHP. First of all you need to acquire an API key: 




1) Go to the Google Developers Console

2) Select a project, or create a new one. 

3) In the sidebar on the left, expand APIs & auth. Next, click APIs. In the list of APIs, make sure the status is ON for the PageSpeed Insights API. 

4) In the sidebar on the left, select Credentials

5) This API supports two types of credentials. You need only Public API access: A request that does not provide an OAuth 2.0 token must send an API key. The key identifies your project and provides API access, quota, and reports.

To create an API key, click Create new Key and select the appropriate key type. Enter the additional information required for that key type and click Create.

Replace "API_KEY" with your ones in following php function.


<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/

function checkPageSpeed($url){  
  if (function_exists('file_get_contents')) {  
    $result = @file_get_contents($url);  
  }  
  if ($result == '') {  
    $ch = curl_init();  
    $timeout = 60;  
    curl_setopt($ch, CURLOPT_URL, $url);  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);  
    $result = curl_exec($ch);  
    curl_close($ch);  
  }  

  return $result;  
}

?>

HOW TO USE CODE
<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/

$myKEY = "API_KEY";
$url = "http://4evertutorials.blogspot.com";
$url_req = 'https://www.googleapis.com/pagespeedonline/v1/runPagespeed?url='.$url.'&key='.$myKEY;
$results = checkPageSpeed($url_req);
echo '
';
print_r(json_decode($results,true)); 
echo '
'; ?>

Friday, August 29, 2014

php linkedin company search and group search


Hello programmers, here is simple php code to extract companies and groups details which has linkedin profile. You need only pass search keyword in URL for companies or groups to get their details. It will return a JSON response with id, head line, logo url, displayname, subline, profile url

For example a search of "google" would be
http://www.linkedin.com/ta/federator?query=google&types=company,group,sitefeature

Please keep in mind linkedin API does not seem to have this feature. If you need linkedin API, please feel free to read through the documentation here.

Usage of code

<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/

$companies = file_get_contents('http://www.linkedin.com/ta/federator?query=google&types=company,group,sitefeature');

$results = json_decode($companies,true);

echo "
";
print_r($results);
echo "
"; ?>
Output returns
 
<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/

Array
(
    [company] => Array
        (
            [resultList] => Array
                (
                    [0] => Array
                        (
                            [id] => 1441
                            [headLine] => Google
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/3/000/062/2ff/080cae8.png
                            [displayName] => Google
                            [subLine] => Internet; 10,001+ employees
                            [url] => http://www.linkedin.com/company/1441
                        )

                    [1] => Array
                        (
                            [id] => 2486941
                            [headLine] => Google SEO (Page 1 Google)
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/4/000/139/37d/3d91dea.png
                            [displayName] => Google SEO (Page 1 Google)
                            [subLine] => Internet; 1-10 employees
                            [url] => http://www.linkedin.com/company/2486941
                        )

                    [2] => Array
                        (
                            [id] => 3017073
                            [headLine] => Google / Titan Aerospace
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/6/000/220/1c0/16d865f.png
                            [displayName] => Google / Titan Aerospace
                            [subLine] => Airlines/Aviation; 11-50 employees
                            [url] => http://www.linkedin.com/company/3017073
                        )

                    [3] => Array
                        (
                            [id] => 621453
                            [headLine] => Wildfire by Google
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/2/000/18f/281/144bd3b.png
                            [displayName] => Wildfire by Google
                            [subLine] => Computer Software; 201-500 employees
                            [url] => http://www.linkedin.com/company/621453
                        )

                    [4] => Array
                        (
                            [id] => 1176352
                            [headLine] => Geoambiente - Google Enterprise Partner
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/8/005/056/2ff/10d57ab.png
                            [displayName] => Geoambiente - Google Enterprise Partner
                            [subLine] => Information Technology and Services; 51-200 employees
                            [url] => http://www.linkedin.com/company/1176352
                        )

                    [5] => Array
                        (
                            [id] => 791962
                            [headLine] => Adometry by Google
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/1/000/18e/2ac/0e9319c.png
                            [displayName] => Adometry by Google
                            [subLine] => Marketing and Advertising; 51-200 employees
                            [url] => http://www.linkedin.com/company/791962
                        )

                    [6] => Array
                        (
                            [id] => 9863
                            [headLine] => ITA Software by Google
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/3/000/0ae/217/0b991b7.png
                            [displayName] => ITA Software by Google
                            [subLine] => Computer Software; 10,001+ employees
                            [url] => http://www.linkedin.com/company/9863
                        )

                    [7] => Array
                        (
                            [id] => 2871869
                            [headLine] => Google Account Managers
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/7/000/1e3/199/293d5b2.png
                            [displayName] => Google Account Managers
                            [subLine] => Marketing and Advertising; 1-10 employees
                            [url] => http://www.linkedin.com/company/2871869
                        )

                    [8] => Array
                        (
                            [id] => 2321528
                            [headLine] => Google AdWords Certified
                            [displayName] => Google AdWords Certified
                            [subLine] => Marketing and Advertising; Myself Only
                            [url] => http://www.linkedin.com/company/2321528
                        )

                    [9] => Array
                        (
                            [id] => 2287804
                            [headLine] => Googlelearn
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/3/000/0da/002/023b4ef.png
                            [displayName] => Googlelearn
                            [subLine] => Education Management; Myself Only
                            [url] => http://www.linkedin.com/company/2287804
                        )

                    [10] => Array
                        (
                            [id] => 3215165
                            [headLine] => Squared Online - a Google / HLC Partnership
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/6/005/056/2d9/33a677d.png
                            [displayName] => Squared Online - a Google / HLC Partnership
                            [subLine] => E-Learning; 11-50 employees
                            [url] => http://www.linkedin.com/company/3215165
                        )

                    [11] => Array
                        (
                            [id] => 2336657
                            [headLine] => Google Apps Authorized Reseller | Bmeet.it
                            [displayName] => Google Apps Authorized Reseller | Bmeet.it
                            [subLine] => Information Technology and Services; Myself Only
                            [url] => http://www.linkedin.com/company/2336657
                        )

                    [12] => Array
                        (
                            [id] => 762501
                            [headLine] => Bump Technologies (acquired by Google)
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/4/000/14c/1a4/3079095.png
                            [displayName] => Bump Technologies (acquired by Google)
                            [subLine] => Wireless; 11-50 employees
                            [url] => http://www.linkedin.com/company/762501
                        )

                    [13] => Array
                        (
                            [id] => 2093403
                            [headLine] => Video Marketing, VSEO, Google Places Optimization, Page One of Google at Cary Duke
                            [displayName] => Video Marketing, VSEO, Google Places Optimization, Page One of Google at Cary Duke
                            [subLine] => Marketing and Advertising; Myself Only
                            [url] => http://www.linkedin.com/company/2093403
                        )

                    [14] => Array
                        (
                            [id] => 2372226
                            [headLine] => Focus BC - EMEA Google Enterprise Partner
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/1/005/03d/3d5/1f046f8.png
                            [displayName] => Focus BC - EMEA Google Enterprise Partner
                            [subLine] => Management Consulting; 11-50 employees
                            [url] => http://www.linkedin.com/company/2372226
                        )

                    [15] => Array
                        (
                            [id] => 3489855
                            [headLine] => PANOSUR - Google Maps Business Views certified Photographer
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/1/005/081/09e/08920d6.png
                            [displayName] => PANOSUR - Google Maps Business Views certified Photographer
                            [subLine] => Photography; 1-10 employees
                            [url] => http://www.linkedin.com/company/3489855
                        )

                    [16] => Array
                        (
                            [id] => 3361424
                            [headLine] => Arroba System - Google Apps Authorized Reseller
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/7/005/019/37e/1933930.png
                            [displayName] => Arroba System - Google Apps Authorized Reseller
                            [subLine] => Internet; 11-50 employees
                            [url] => http://www.linkedin.com/company/3361424
                        )

                    [17] => Array
                        (
                            [id] => 978865
                            [headLine] => WIMM Labs (acquired by Google)
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/1/000/071/203/0b3d11a.png
                            [displayName] => WIMM Labs (acquired by Google)
                            [subLine] => Consumer Electronics; 11-50 employees
                            [url] => http://www.linkedin.com/company/978865
                        )

                    [18] => Array
                        (
                            [id] => 3081545
                            [headLine] => Google Virksomhedsbilleder: Google går indenfor i din virksomhed
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/2/000/241/1af/2f5a4b8.png
                            [displayName] => Google Virksomhedsbilleder: Google går indenfor i din virksomhed
                            [subLine] => Photography; Myself Only
                            [url] => http://www.linkedin.com/company/3081545
                        )

                    [19] => Array
                        (
                            [id] => 3200505
                            [headLine] => Google International
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/5/005/042/1fa/3d1c00e.png
                            [displayName] => Google International
                            [subLine] => Legal Services; 11-50 employees
                            [url] => http://www.linkedin.com/company/3200505
                        )

                )

        )

    [group] => Array
        (
            [resultList] => Array
                (
                    [0] => Array
                        (
                            [id] => 4248784
                            [headLine] => Google
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/3/000/128/301/196fb6a.png
                            [displayName] => Google
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=4248784&mostPopular=
                        )

                    [1] => Array
                        (
                            [id] => 4006283
                            [headLine] => GOOGLE+
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/3/000/0d7/077/064bc0b.png
                            [displayName] => GOOGLE+
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=4006283&mostPopular=
                        )

                    [2] => Array
                        (
                            [id] => 76373
                            [headLine] => Google Android
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/1/000/01f/3e7/2fd0a55.png
                            [displayName] => Google Android
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=76373&mostPopular=
                        )

                    [3] => Array
                        (
                            [id] => 2930475
                            [headLine] => Google Universe : Jobs, Tools, Trends and Galaxies of Ideas
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/2/000/057/1c8/2bc17fb.png
                            [displayName] => Google Universe : Jobs, Tools, Trends and Galaxies of Ideas
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=2930475&mostPopular=
                        )

                    [4] => Array
                        (
                            [id] => 1604367
                            [headLine] => Google Analytics
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/1/000/01f/0e8/326ef60.png
                            [displayName] => Google Analytics
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=1604367&mostPopular=
                        )

                    [5] => Array
                        (
                            [id] => 37724
                            [headLine] => Google Adwords Qualified Individuals
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/3/000/000/2fa/137b4fa.png
                            [displayName] => Google Adwords Qualified Individuals
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=37724&mostPopular=
                        )

                    [6] => Array
                        (
                            [id] => 85376
                            [headLine] => Google Apps
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/2/000/007/2c8/1b2d372.png
                            [displayName] => Google Apps
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=85376&mostPopular=
                        )

                    [7] => Array
                        (
                            [id] => 1825251
                            [headLine] => Google Professional Network
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/1/005/020/06c/2dedc76.png
                            [displayName] => Google Professional Network
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=1825251&mostPopular=
                        )

                    [8] => Array
                        (
                            [id] => 107462
                            [headLine] => Google APPS users
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/1/000/0a8/310/195dc10.png
                            [displayName] => Google APPS users
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=107462&mostPopular=
                        )

                    [9] => Array
                        (
                            [id] => 3190679
                            [headLine] => Google Adwords SEO SEM (Search Engine Optimization & Internet Marketing)
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/3/000/063/225/3d1ab3b.png
                            [displayName] => Google Adwords SEO SEM (Search Engine Optimization & Internet Marketing)
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=3190679&mostPopular=
                        )

                    [10] => Array
                        (
                            [id] => 3066064
                            [headLine] => Google Android TV
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/4/000/132/34b/148cc74.png
                            [displayName] => Google Android TV
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=3066064&mostPopular=
                        )

                    [11] => Array
                        (
                            [id] => 95911
                            [headLine] => Google Adwords
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/1/000/008/327/0b214eb.png
                            [displayName] => Google Adwords
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=95911&mostPopular=
                        )

                    [12] => Array
                        (
                            [id] => 36431
                            [headLine] => Google Alumni
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/1/000/00c/33f/0724411.png
                            [displayName] => Google Alumni
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=36431&mostPopular=
                        )

                    [13] => Array
                        (
                            [id] => 128878
                            [headLine] => Google App Engine Developers
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/1/000/00b/325/2709731.png
                            [displayName] => Google App Engine Developers
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=128878&mostPopular=
                        )

                    [14] => Array
                        (
                            [id] => 1840064
                            [headLine] => Google Analytics Qualified Individuals
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/2/000/01e/38e/1919a0b.png
                            [displayName] => Google Analytics Qualified Individuals
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=1840064&mostPopular=
                        )

                    [15] => Array
                        (
                            [id] => 4022728
                            [headLine] => Google Plus Marketing
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/1/000/0e5/2dc/34faf4e.png
                            [displayName] => Google Plus Marketing
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=4022728&mostPopular=
                        )

                    [16] => Array
                        (
                            [id] => 1873841
                            [headLine] => Google Apps Solution Providers
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/3/000/020/345/2803f2e.png
                            [displayName] => Google Apps Solution Providers
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=1873841&mostPopular=
                        )

                    [17] => Array
                        (
                            [id] => 2768916
                            [headLine] => Google+ and Google Products for Nonprofit Organizations
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/1/000/080/2fd/0d176f3.png
                            [displayName] => Google+ and Google Products for Nonprofit Organizations
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=2768916&mostPopular=
                        )

                    [18] => Array
                        (
                            [id] => 93548
                            [headLine] => Google Adwords Professional Group
                            [displayName] => Google Adwords Professional Group
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=93548&mostPopular=
                        )

                    [19] => Array
                        (
                            [id] => 1772976
                            [headLine] => Google SEO en Zoekmachine Professionals Nederland
                            [imageUrl] => http://m.c.lnkd.licdn.com/mpr/mpr/shrink_40_40/p/4/005/03b/12f/3d921f3.png
                            [displayName] => Google SEO en Zoekmachine Professionals Nederland
                            [subLine] => 
                            [url] => http://www.linkedin.com/groups?gid=1772976&mostPopular=
                        )

                )

        )

)


?>

Saturday, August 23, 2014

php capture website screenshot script

In this post we learn how to take websites screenshots very easily in PHP using Grabz.it 's API. First of all you need to create grabz.it account  to get API keys (APPLICATION KEY and APPLICATION SECRET) . Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account. The best way to put website screenshots into your PHP application is by using our simple PHP API.
<?php

/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.com/
*/
include("GrabzItClient.class.php");

$grabzIt = new GrabzItClient("APPLICATION KEY", "APPLICATION SECRET");// Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account!

// To take a image screenshot
$grabzIt->SetImageOptions("http://www.google.com");     
// Or to take a PDF screenshot
$grabzIt->SetPDFOptions("http://www.google.com");
// Or to capture table(s)
$grabzIt->SetTableOptions("http://www.google.com");

?>

Above code is used to create class object with your account API key and secret after creating object we are calling 3 different methods SetImageOptions used to capture image of given page output, SetPDFOptions used to create PDF of given url and SetTableOptions is used to extract tables from the web page.

More Options

There are many more options including; configuring the browser height, browser width, screenshot height, screenshot width, the delay before a screenshot is taken and the image format of the screenshot. For all these options please see the Client documentation.


 

© 2014 4everTutorials. All rights resevered.

Back To Top