domingo, 31 de diciembre de 2017
php printing a date object
<?php
$date=date_create("2013-03-15");
echo date_format($date,"Y/m/d H:i:s");
?>
https://www.w3schools.com/php/func_date_date_format.asp
lunes, 25 de diciembre de 2017
php jquery pagination
https://datatables.net/
http://www.kodingmadesimple.com/2017/12/jquery-datatables-php-mysql-ajax.html?utm_content=buffer1b30d&utm_medium=social&utm_source=facebook.com&utm_campaign=buffer
http://www.kodingmadesimple.com/2017/12/jquery-datatables-php-mysql-ajax.html?utm_content=buffer1b30d&utm_medium=social&utm_source=facebook.com&utm_campaign=buffer
sábado, 23 de diciembre de 2017
php curl example
<?php
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://www.php.net");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($curl);
curl_close ($curl);
print $result;
?>
<?php $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,"http://localhost/posttest.php"); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, "Hello=World&Foo=Bar&Baz=Wombat"); curl_exec ($curl); curl_close ($curl); ?>
http://php.net/manual/en/function.curl-setopt.php
http://www.hackingwithphp.com/15/10/2/your-first-curl-scripts
<?php $curl = curl_init(); curl_setopt($curl, CURLOPT_URL,"http://localhost/posttest.php"); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, "Hello=World&Foo=Bar&Baz=Wombat"); curl_exec ($curl); curl_close ($curl); ?>
http://php.net/manual/en/function.curl-setopt.php
http://www.hackingwithphp.com/15/10/2/your-first-curl-scripts
jueves, 21 de diciembre de 2017
twilio response to sms
<?php
$number = $_POST['From'];
$body = $_POST['Body'];
header('Content-Type: text/xml');
?>
<Response>
<Message>
Hello <?php echo $number ?>.
You said <?php echo $body ?>
</Message>
</Response>
https://www.twilio.com/blog/2016/08/receive-sms-php-twilio.html
$number = $_POST['From'];
$body = $_POST['Body'];
header('Content-Type: text/xml');
?>
<Response>
<Message>
Hello <?php echo $number ?>.
You said <?php echo $body ?>
</Message>
</Response>
https://www.twilio.com/blog/2016/08/receive-sms-php-twilio.html
Setup Twilio Phone Number
Sign up for a free Twilio account if you don’t have one.
Buy a phone number, then click Setup Number. Scroll to the Messaging section and find the line that says “A Message Comes In.”
Fill in the full path to your file (i.e., https://yourserver.com/message.php) and click Save.
Now, send an SMS to your shiny new phone number number and revel in the customized response that comes back your way.
miércoles, 20 de diciembre de 2017
php xml
<!DOCTYPE html>
<html>
<body>
<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML;
$xml=simplexml_load_string($note);
echo $xml->getName() . "<br>";
foreach($xml->children() as $child)
{
echo $child->getName() . ": " . $child . "<br>";
}
?>
</body>
</html>
Tove
Jani
Reminder
Don't forget me this weekend!
------------------------------------------------
<!DOCTYPE html>
<html>
<body>
<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML;
$xml=simplexml_load_string($note);
echo $xml->to . "<br>";
echo $xml->from . "<br>";
echo $xml->heading . "<br>";
echo $xml->body;
?>
</body>
</html>
Tove
Jani
Reminder
Don't forget me this weekend!
https://www.w3schools.com/PhP/func_simplexml_load_string.asp
<html>
<body>
<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML;
$xml=simplexml_load_string($note);
echo $xml->getName() . "<br>";
foreach($xml->children() as $child)
{
echo $child->getName() . ": " . $child . "<br>";
}
?>
</body>
</html>
Tove
Jani
Reminder
Don't forget me this weekend!
------------------------------------------------
<!DOCTYPE html>
<html>
<body>
<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML;
$xml=simplexml_load_string($note);
echo $xml->to . "<br>";
echo $xml->from . "<br>";
echo $xml->heading . "<br>";
echo $xml->body;
?>
</body>
</html>
Tove
Jani
Reminder
Don't forget me this weekend!
https://www.w3schools.com/PhP/func_simplexml_load_string.asp
jueves, 14 de diciembre de 2017
php loading xml into array
<?php
$xmlstring=file_get_contents("http://180.110.13.81/default/en_US/send_sms_status.xml");
$xml = simplexml_load_string($xmlstring);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
print_r($array);
echo " $array[smskey1] $array[status1] $array[error1]";
?>
$xmlstring=file_get_contents("http://180.110.13.81/default/en_US/send_sms_status.xml");
$xml = simplexml_load_string($xmlstring);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
print_r($array);
echo " $array[smskey1] $array[status1] $array[error1]";
?>
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<send-sms-status>
<smskey1>697409980</smskey1>
<status1>DONE</status1>
<error1/>
<smskey2/>
<status2/>
<error2/>
<smskey3/>
<status3/>
<error3/>
<smskey4/>
<status4/>
<error4/>
<smskey5/>
<status5/>
<error5/>
<smskey6/>
<status6/>
<error6/>
<smskey7/>
<status7/>
<error7/>
<smskey8/>
<status8/>
<error8/>
</send-sms-status>
php .=
<?php
$rand="18097143489_";
$rand .= rand();
$rand="18097143489_";
$rand .= rand();
echo $rand;
?>
18097143489_1693751741
viernes, 8 de diciembre de 2017
creating a csv with dowload
<?php
$csv_file = "csv_export_".date('Ymd') . ".csv";
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=\"$csv_file\"");
$out = fopen('php://output', 'w');
$list=array('Name','LastName', 'Age' 'Address', 'state');
fputcsv($out, $list);
fclose($out);
?>
http://php.net/manual/en/function.fputcsv.php
http://www.phpzag.com/create-a-csv-file-using-phpmysql/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+phpzag+%28PHP+Tutorial%29
$csv_file = "csv_export_".date('Ymd') . ".csv";
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=\"$csv_file\"");
$out = fopen('php://output', 'w');
$list=array('Name','LastName', 'Age' 'Address', 'state');
fputcsv($out, $list);
fclose($out);
?>
http://php.net/manual/en/function.fputcsv.php
http://www.phpzag.com/create-a-csv-file-using-phpmysql/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+phpzag+%28PHP+Tutorial%29
writing to a csv with fputcsv
<?php
$list = array
(
"Peter,Griffin,Oslo,Norway",
"Glenn,Quagmire,Oslo,Norway",
);
$file = fopen("contacts.csv","w");
foreach ($list as $line)
{
fputcsv($file,explode(',',$line));
}
fclose($file); ?>
The CSV file will look like this after the code above has been executed:
Peter,Griffin,Oslo,Norway
Glenn,Quagmire,Oslo,Norway
sábado, 2 de diciembre de 2017
google translation API
composer require google/cloud-translate
<?php
# Includes the autoloader for libraries installed with composer
require __DIR__ . '/vendor/autoload.php';
# Imports the Google Cloud client library
use Google\Cloud\Translate\TranslateClient;
# Your Google Cloud Platform project ID
$projectId = 'voice-184406';
# Your Google login information
putenv('GOOGLE_APPLICATION_CREDENTIALS=/var/www/html/google_api/voice.json');
# Instantiates a client
$translate = new TranslateClient([
'projectId' => $projectId
]);
####variables####
$text=$argv['1'];
$lang=$argv['2'];
# The text to translate
# The target language
$target = "$lang";
# Translates some text into spanish
$translation = $translate->translate($text, [
'target' => $target
]);
echo 'Text: ' . $text . '
Translation: ' . $translation['text'];
?>
php translator.php " Hola gracias por leer este articulo" en
Text: Hola gracias por leer este articulo
Translation: Hi, thanks for reading this article
https://cloud.google.com/translate/docs/reference/libraries
https://cloud.google.com/translate/docs/languages
Suscribirse a:
Entradas (Atom)