Search:

Categories



Get google plus ones for a domain name

<?php
$url = "http://www.facebook.com";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://clients6.google.com/rpc");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"'.rawurldecode($url).'","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
$curl_results = curl_exec ($curl);
curl_close ($curl);
$json = json_decode($curl_results, true);
echo $json[0]['result']['metadata']['globalCounts']['count'];
?>
Share

Get average feedburner reader numbers

function get_average_readers($feed_id,$interval = 7)
{
$today = date(‘Y-m-d’, strtotime("now"));
$ago = date(‘Y-m-d’, strtotime("-".$interval." days"));
$feed_url="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=".$feed_id."&dates=".$ago.",".$today;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $feed_url);
$data = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry[‘circulation’];
 
$nb = 0;
foreach($xml->feed->children() as $circ){
  $nb += $circ[‘circulation’];
}
 
return round($nb/$interval);
}

Share

Currency conversion

 

function currency($from_Currency,$to_Currency,$amount)
{
$amount = urlencode($amount);
$from_Currency = urlencode($from_Currency);
$to_Currency = urlencode($to_Currency);
$url = "http://www.google.com/ig/calculator?hl=en&q=$amount$from_Currency=?$to_Currency";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,  CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$rawdata = curl_exec($ch);
curl_close($ch);
$data = explode(‘"’, $rawdata);
$data = explode(‘ ‘, $data[‘3’]);
$var = $data[‘0’];
return round($var,2);
}

Share

Latest weather using PHP

<?php 
  $xml = simplexml_load_file(‘http://www.google.com/ig/api?weather=ADDRESS’);
  $information = $xml->xpath("/xml_api_reply/weather/current_conditions/condition");
  echo $information[0]->attributes();
?>

Share

A google pagerank script

A google pagerank script

<?php
function page_rank($site)
{
   
$url = ‘http://google.com/search?client=navclient-auto&ch=6-1484155081&features=Rank&q=info:’;
$fp = fopen($url.’http://’.$site, ‘r’);
$content = fread($fp, 200000);
fclose($fp);

$rank = explode(‘:’,$content);
if($rank[2] != ”)
    return $rank[2];
else
    return FALSE;
break;

}
echo ‘Google Rank: ‘.page_rank(‘getphp.net’);
?>

Share

PHP Tutorial: Installation and The Basics

jimmyrcom asked:

To get php and apache installed use xampp.
xampp is free and contains php / apache (around 33mb)

1. Download and Install XAMPP from here:
http://www.apachefriends.org/en/xampp.html

2. on windows go to C:\xampp

it should have a folder called htdocs. If you put a file called foo.html
into the htdocs folder you should be able to access it by going to
http://localhost/foo.html or /foo.php.

There’s also something called WAMP
http://www.wampserver.com/en/

There’s a lot of php tutorials out there just search google
http://www.google.com/search?hl=enr&q=php%20tutorial

Request tutorials here
http://youtube.jimmyr.com/
More PHP TUtorials here
http://killerphp.com/

Some people have recommended other editors
http://www.scintilla.org/SciTE.html
http://www.pspad.com/
http://en.wikipedia.org/wiki/Comparison_of_text_editors
http://www.context.cx/

%%programming

Share