PHPにて重い処理を行う場合
exec(“nohup php -c ” ‘mail.php’ > /dev/null &”);
PHPにて重い処理を別スレッドで実行する方法
http://web-terminal.blogspot.jp/2013/04/php.html
PHPでマルチスレッド(バックグラウンド処理)を実現する方法
http://techblog.ecstudio.jp/tech-tips/php-multi.html
php、MySQLそれにかかわるweb全般自分用メモ
PHPにて重い処理を行う場合
exec(“nohup php -c ” ‘mail.php’ > /dev/null &”);
PHPにて重い処理を別スレッドで実行する方法
http://web-terminal.blogspot.jp/2013/04/php.html
PHPでマルチスレッド(バックグラウンド処理)を実現する方法
http://techblog.ecstudio.jp/tech-tips/php-multi.html
twitterで画像付き投稿
<?php
// OAuth認証
$user = “ユーザー名”;
$consumer_key = “キー”;
$consumer_secret = “シークレット”;
$access_token = “トークンキー”;
$access_token_secret = “トークンシークレット”;
$tmhOAuth = new tmhOAuth(array(
‘consumer_key’ => $consumer_key,
‘consumer_secret’ => $consumer_secret,
‘user_token’ => $access_token,
‘user_secret’ => $access_token_secret,
‘curl_ssl_verifypeer’ => false,
));
$message=”ほげほげ”;
// 画像付きツイート
$code = $tmhOAuth->request(‘POST’, ‘https://api.twitter.com/1.1/statuses/update_with_media.json’,
array(
‘media[]’ => “@{$image}”,
‘status’ => $message
),
true,
true // multipart/form-data
);
}
smartyでエンコードは
{$hoge|escape:”url”}
TwitterAPIの仕様が2014/1/15にかわったようだ。
http を https に変更すれば直る。
$to->OAuthRequest(“http://api.twitter.com/1.1/statuses/update.json”~
を
$to->OAuthRequest(“https://api.twitter.com/1.1/statuses/update.json”~
に
jQuery Mobileの戻る無効化
Ajax無効化設定とブラウザの戻るバグ対策
ツイッターが凍結した。
<?php
//今年
$toyear = date(“Y”);
$toyear1=”$toyear”.”-01-01″;
$toyear2=”$toyear”.”-12-31″;
$holidays_url = sprintf(
‘http://www.google.com/calendar/feeds/%s/public/full-noattendees?start-min=%s&start-max=%s&max-results=%d&alt=json’ ,
‘outid3el0qkcrsuf89fltf7a4qbacgt9@import.calendar.google.com’ , ,
“$toyear1” , // 取得開始日
“$toyear2″ , // 取得終了日
50 // 最大取得数
);
if ( $results = file_get_contents($holidays_url) ) {
$results = json_decode($results, true);
$holidays = array();
foreach ($results[‘feed’][‘entry’] as $val ) {
$date = $val[‘gd$when’][0][‘startTime’];
$title = $val[‘title’][‘$t’];
$title = preg_replace(‘!/[^/]*!’, ‘/’, $title);
$title = str_replace(‘/’, ”, $title);
$holidays[$date] = $title;
}
ksort($holidays);
foreach($holidays as $key => $value){
echo $key.” “.$value.”<br />”;
}
POSTされたデータ確認。
echo “<pre>”;
print_r($_POST);
echo “</pre>”;
php.ini precision のデフォルトが12だったので13桁の数値計算ができず
.htaccessに以下追加
php_value precision 16
precision integer
浮動小数点数に関して表示される最大桁数を指定します。