我在cpanel中添加了cronjob以在php中使用textloal发送短信。它在cronjob外部完美运行。在cronjob中运行它后,它不会发送任何短信。
这是我的代码
<?php
include('dbc.php');
error_reporting(E_ALL); ini_set('display_errors', 1);
require('php-in/textlocal.class.php');
//require('php-in\Textlocal.class.php');
//require('consultantnext.com/danceschool/php-in/Textlocal.class.php');
$sql="SELECT *
FROM admin t1, batchinfo t2
WHERE t1.batchname= t2.batchname
AND t1.branchname= t2.branchname";
$result= mysqli_query($conn,$sql)
or die($sql."<br/><br/>".mysql_error());
if (mysqli_num_rows($result)>0) {
while($row=mysqli_fetch_array($result)) {
//echo $row['mobile'];
$mobile=$row['mobile'];
$time=$row['time'];
//echo $time;
$numbers=(explode(" ",$mobile));
foreach ($numbers as $item) {
echo $item;
}
$Textlocal = new Textlocal(false, false, 'e34FsEpkeUo-
uLJ17oDYeEgHBucRHTnNtHhrE39Pj4');
//$numbers = array(919384191234,918056377914);
$sender = 'TXTLCL';
$message = "Dear student your class schedule for tomorrow '$time'";
$response = $Textlocal->sendSms($numbers, $message, $sender);
print_r($response);
//echo $message;
}
}
$sql="SELECT * FROM admin
WHERE username NOT IN (
SELECT studentname
FROM transcation
WHERE MONTH(DATE(date))=MONTH(CURDATE())
)
and usertype='student' ";
$result= mysqli_query($conn, $sql)
or die($sql."<br/><br/>".mysql_error());
If(mysqli_num_rows($result)>0) {
while($row=mysqli_fetch_array($result)) {
$username=$row['username'];
echo $username;
$mobile=$row['mobile'];
$numbers=(explode(" ",$mobile));
foreach ($numbers as $item) {
echo $item;
}
$Textlocal = new Textlocal(false, false, 'e34FsEpkeUo-
uLJ17oDYeEgHBucRHTnNtHhrE39Pj4');
$sender = 'TXTLCL';
$message = "Dear student please pay the fees before due date. ";
$response = $Textlocal->sendSms($numbers, $message, $sender);
print_r($response);
}
}
这是我的命令:
/usr/local/bin/php /home/cpdarmkr/public_html/danceschool/message.php
答案 0 :(得分:0)
问题可能不在您的代码中,而是在您的命令中。也许尝试此命令,它可能会起作用:
* * * * * /usr/bin/php -q /home/cpdarmkr/public_html/danceschool/message.php
答案 1 :(得分:0)
这对我有用
使用cURL:
import tensorflow as tf
import numpy as np
tf.reset_default_graph()
x_shape = [1, 4, 4, 1]
x_val = np.ones(shape=x_shape)
x_val[0,1,1,0]=5
print(x_val)
x_data = tf.placeholder(tf.float32, shape=x_shape)
my_filter = tf.constant(0.25, shape=[2, 2, 1, 1])
my_strides = [1, 2, 2, 1]
mov_avg_layer= tf.nn.conv2d(x_data, my_filter, my_strides,
padding='SAME', name='Moving_Avg_Window')
# Execute the operations
with tf.Session() as sess:
#print(x_data.eval())
result =sess.run(mov_avg_layer,feed_dict={x_data: x_val})
print("Filter: " , result)
print("Filter: " , result.shape)
sess.close()