How to Get Google +1 Count for Current Page in PHP

Difficulty getting google plus one count

Probably a problem with curl not accepting the CA of the server. You can find out for sure with:

$curl_results = curl_exec ($ch);
echo curl_error($ch);

If it is indeed a problem with the untrusted CA, you have two options. The insecure and easy way would be to add one more option to curl:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

This disables the check. The second option (better and a bit more complicated) would be to go to https://clients6.google.com and export the CA certificate and feed it to curl like so:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/CAcerts/exported.crt");

Difficulty getting google plus one count

Probably a problem with curl not accepting the CA of the server. You can find out for sure with:

$curl_results = curl_exec ($ch);
echo curl_error($ch);

If it is indeed a problem with the untrusted CA, you have two options. The insecure and easy way would be to add one more option to curl:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

This disables the check. The second option (better and a bit more complicated) would be to go to https://clients6.google.com and export the CA certificate and feed it to curl like so:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/CAcerts/exported.crt");

pagination count range of products on current page

Try:

echo "Showing ".( $page == 1 ? 1 : ($page -1) * $recordsLimit +1 )." to ".($page * $recordsLimit)." item of ".$totalProducts;

How to get current page using start index, items per page, total items, and total pages? (PHP)

With 10 items per page and assuming your item count/numbering starts at 1, page 1 contains items 1 to 10, page 2 contains items 11 to 20, page 3 contains 21 to 30, and so on.

So,

$currentPage = ceil(($startIndex - 1) / $itemsPerPage) + 1;

I used ceil() to make sure you have an integer number, which is rounded up so the current page number is correct.


If your item count starts at 0, so page 1 contains items 0 to 9, you can skip the - 1 and + 1 parts of the formula:

$currentPage = ceil(($startIndex) / $itemsPerPage);

Get Particular Page view count in Google analytics using PHP

In order to get data for each page path you will need to add ga:pagePath as a dimension. i.e.

$pagePath = new Google_Service_AnalyticsReporting_Dimension();
$pagePath->setName("ga:browser");

// Later on

$request->setDimensions(array($pagePath));

You can also filter your data by dimension so you only see results that fit a criteria. For example, only show data for your signup page by adding the filter as follows:

// Create the DimensionFilter.
$dimensionFilter = new Google_Service_AnalyticsReporting_DimensionFilter();
$dimensionFilter->setDimensionName('ga:pagePath');
$dimensionFilter->setOperator('EXACT');
$dimensionFilter->setExpressions(array('/signup'));

// Create the DimensionFilterClauses
$dimensionFilterClause = new Google_Service_AnalyticsReporting_DimensionFilterClause();
$dimensionFilterClause->setFilters(array($dimensionFilter));

//Later on

$request->setDimensionFilterClauses(array($dimensionFilterClause));


Related Topics



Leave a reply



Submit