$URL="http://api.ipinfodb.com/v3/ip-city/?key=tuakey&ip=$ip&format=json";
#####per la citta ip-city##############
#echo"$URL
";
$URL = rawurldecode($URL);
$URL = stripslashes($URL);
// make sure curl is installed
if (function_exists('curl_init')) {
// initialize a new curl resource
$ch = curl_init();
// set the url to fetch
curl_setopt($ch, CURLOPT_URL, $URL);
// don't give me the headers just the content
curl_setopt($ch, CURLOPT_HEADER, 0);
// return the value instead of printing the response to browser
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// use a user agent to mimic a browser
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
$content = curl_exec($ch);
#echo $content;
// remember to always close the session and free all resources
curl_close($ch);
} else {
// curl library is not installed so we better use something else
}
#####################################################################
$json=$content;
$obj = json_decode($json);
$regionName=$obj->{'regionName'}; // 12345
$cityName=$obj->{'cityName'}; // 12345
echo"#$regionName#";
Una serie di codici sperimentati, e quindi funzionanti, di php e css per l'ottimizzazione dei siti web sui motori di ricerca.
Iscrizione diretta da sito alla newsletters di MailUp Api
Con curl e php è molto facile far iscrivere un cliente alla newsletters di MailUp, ecco il codice:
$url="http://[tuo_admin_url]/frontend/subscribe.aspx?idMsg=2&idList=1&email=luca@icewebsolution.it&confirm=false";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
// curl_setopt($ch,CURLOPT_HEADER, false);
$output=curl_exec($ch);
curl_close($ch);
return $output;
?>
comodo anche nel modulo della registrazione.
$url="http://[tuo_admin_url]/frontend/subscribe.aspx?idMsg=2&idList=1&email=luca@icewebsolution.it&confirm=false";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
// curl_setopt($ch,CURLOPT_HEADER, false);
$output=curl_exec($ch);
curl_close($ch);
return $output;
?>
comodo anche nel modulo della registrazione.
Php e curl per compilare in automatico un form
Semplice codice curl+php per compilare un form in automatico, da usare con parsimonia:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/path/to/form");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
$data = array(
'foo' => 'foo foo foo',
'bar' => 'bar bar bar',
'baz' => 'baz baz baz'
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
usato per postare in automatico su Pinterest
Il totale dei like, share e commenti del nostro sito su Facebook
Per chi vuole conoscere un po' di dati del nostro sito su Facebook, https://api.facebook.com/method/links.getStats?urls=%%URL%%&format=json
Iscriviti a:
Post (Atom)