Да, но этот цикл не занимается ничем кроме как что проверяет и вызывает и поэтому это кажется быстрым, т.е. асинхронным
![smile.gif](http://phpforum.su/html/emoticons/smile.gif)
_____________
Gear Framework
Gear Framework на Github
exec("nohup php -q /var/www/domain/fb_post.php action=king access_token={$post['access_token']} userid={$post['userid']} name={$user['name']} >> script_log.txt 2>&1 &");
X-Powered-By: PHP/5.4.20
Content-type: application/json
Content-Type: text/html; charset=utf-8
{"success":true}
echo "<pre>";
print_r($argv);
echo "</pre>";
die();
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
Цитата (SoMeOnE @ 6.02.2014 - 00:49) |
из-за htaccess может быть ? |
Цитата (killer8080 @ 6.02.2014 - 07:14) |
Без nohup пробовал? По идее он и сам должен в бэкграунд уйти. |
echo exec('whoami');
echo exec('pwd');
Цитата (SoMeOnE @ 6.02.2014 - 00:43) |
На сервере не работает. А в script_log.txt много раз записывается (около 300 повторов) X-Powered-By: PHP/5.4.20 Content-type: application/jsonContent-Type: text/html; charset=utf-8 {"success":true} |
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/'.$parameters['userid'].'/feed');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result= curl_exec($ch);
Цитата (SoMeOnE @ 6.02.2014 - 14:47) |
success true это ответ который не из fb_post.php возвращается. |
<?php
$parameters = array();
foreach ($argv as $param) {
$temp = explode('=', $param);
if (count($temp) == 2) {
$parameters[$temp[0]] = $temp[1];
}
}
$action = $parameters['action'];
switch ($action) {
case 'post':
$attachment = array(
'access_token' => $parameters['access_token'],
'name' => $parameters['name'].' - asdasdasd',
'link' => 'https://www.facebook.com/pages/PARKINGaz/{здесь fan_page_id}',
'description' => $parameters['auto_number'],
'picture' => 'http://domain.com/uploads/cars/small/'.$parameters['photo_name'].'',
);
// set the target url
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/'.$parameters['userid'].'/feed');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result= curl_exec($ch);
curl_close ($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/{здесь fan_page_id}/feed');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result= curl_exec($ch);
curl_close ($ch);
break;
case 'comment':
$attachment = array(
'access_token' => $parameters['access_token'],
'message' => $parameters['comment'],
'name' => $parameters['name'].' - asdasdsd',
'link' => 'https://www.facebook.com/pages/PARKINGaz/{здесь fan_page_id}',
'description' => $parameters['auto_number'],
'picture' => 'http://domain.com/uploads/cars/small/'.$parameters['photo_name'].'',
);
// set the target url
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/'.$parameters['userid'].'/feed');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result= curl_exec($ch);
curl_close ($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/{здесь fan_page_id}/feed');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result= curl_exec($ch);
curl_close ($ch);
break;
case 'king':
$attachment = array(
'access_token' => $parameters['access_token'],
'name' => $parameters['name'].' - asdasdasd',
'link' => 'https://www.facebook.com/pages/PARKINGaz/{здесь fan_page_id}',
'description' => $parameters['auto_number'],
'picture' => 'http://domain.com/uploads/cars/small/'.$parameters['photo_name'].'',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/'.$parameters['userid'].'/feed');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result= curl_exec($ch);
curl_close ($ch);
break;
}
exec("php -q /home/domain/public_html/parking/fb_post.php action=king access_token={$post['access_token']}
userid={$post['userid']} name={$user['name']} auto_number='{$article['auto_number']}' photo_name={$article['photo_name']} >> script_log.txt 2>&1 &");
}
$report['success'] = true;
} else {
$report['success'] = false;
}
} else {
$report['success'] = true;
}
return $report;
}