@ 2014-04-30T05:28:09Z <?php
$now = date('Y-m-d h:20');
$today = date('Y-m-d');
$afternoon = date('Y-m-d 17:27');
// require Facebook PHP SDK
// see: https://developers.facebook.com/docs/php/gettingstarted/
require_once("sdk/facebook.php");
// initialize Facebook class using your own Facebook App credentials
// see: https://developers.facebook.com/docs/php/gettingstarted/#install
$config = array();
$config['appId'] = '290692250950652'; // configure appropriately
$config['secret'] = 'b796627dc623cee90ac49ac806d6b4e8'; // configure appropriately
$config['fileUpload'] = false; // optional
$fb = new Facebook($config);
$user_id="1740048734";
$page_id="127287113972280";
$group_id="115454235207375";
$user_token = array();
$page_token = array();
$user_token['access_token'] = 'CAAEIYhBbWZCwBAEkHQxFNWkdVY52PGapKqccqQX2QlLHM2pqZB1dR7oumasYUhCkAZCW95Ab4f3HmzpPygWXkrHk0fl1t1iaGlfyaCjG04B8shEx3Bp3VzVakM5xZAFBUOLZB3T8TirYWwAGrZBrAEexymrA5YXGYMFgipex0Ho1kmt3BWdhVebcU2GLPJBiMZD';
$fb->setAccessToken($user_token['access_token']);
$accounts = $fb->api('/'.$user_id.'/accounts');
foreach($accounts['data'] as $account){
if($account['id'] == $page_id){
$page_token['access_token'] = $account['access_token'];
}
}
$conn = new mysqli("localhost", "mvawzuyw_admin", "#veyron_153", "mvawzuyw_sharecenter");
if ($conn->connect_error) {
trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR);
}
// create array with topics to be posted on Facebook
$sql = 'SELECT * FROM queue WHERE date IS NOT NULL AND count > 0 ORDER BY date ASC';
$rs = $conn->query($sql);
if($rs === false) {
$user_error = 'Wrong SQL: ' . $sql . '<br>' . 'Error: ' . $conn->errno . ' ' . $conn->error;
trigger_error($user_error, E_USER_ERROR);
}
$rs->data_seek(0);
$share_topics = array();
while($res = $rs->fetch_assoc()) {
$a_topic = array(
"url" => $res["url"],
"title" => $res["title"],
"message" => $res["message"],
"description" => $res["description"],
"image" => $res["image"],
"targets" => $res["targets"],
"event_date" => $res["event_date"],
"photo" => $res["photo"],
"count" => $res["count"],
"date" => $res["date"]
);
array_push($share_topics, $a_topic);
}
$rs->free();
foreach($share_topics as $share_topic) {
if($share_topic['date'] == $now ) {
// define POST parameters
$content = array(
"message" => $share_topic["message"],
"link" => $share_topic["url"],
"name" => $share_topic["title"],
"caption" => "https://sekazone.ro", // configure appropriately
"description" => $share_topic["description"]
);
try {
$ret = $fb->api('/'.$page_id.'/feed', 'POST', array_merge($page_token, $content));
echo 'Successfully posted to Facebook';
} catch(Exception $e) {
echo $e->getMessage();
}
sleep(10);
try {
$ret = $fb->api('/'.$user_id.'/feed', 'POST', array_merge($user_token, $content));
echo 'Successfully posted to Facebook';
} catch(Exception $e) {
echo $e->getMessage();
}
sleep(10);
try {
$ret = $fb->api('/'.$group_id.'/feed', 'POST', array_merge($user_token, $content));
echo 'Successfully posted to Facebook';
} catch(Exception $e) {
echo $e->getMessage();
}
sleep(10);
foreach ($share_topic['targets'] as $value) {
try {
$ret = $fb->api('/'.$value.'/feed', 'POST', array_merge($user_token, $content));
echo 'Successfully posted to Facebook';
} catch(Exception $e) {
echo $e->getMessage();
}
sleep(25);
}
$share_topic["count"] = $share_topic["count"] -1;
$sql = 'UPDATE queue SET count = '.$share_topic['count'].' WHERE url = ' . $share_topic['url'];
if($conn->query($sql) === false) : trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR); endif;
// IS TODAY __________________________________________________________________
} elseif ($share_topic['event_date'] == $today && $now == $afternoon) {
$content = array(
"message" => $share_topic["message"],
"link" => $share_topic["url"],
"name" => $share_topic["title"],
"caption" => "https://sekazone.ro", // configure appropriately
"description" => $share_topic["description"]
);
try {
$ret = $fb->api('/'.$page_id.'/feed', 'POST', array_merge($page_token, $content));
echo 'Successfully posted to Facebook';
} catch(Exception $e) {
echo $e->getMessage();
}
sleep(10);
try {
$ret = $fb->api('/'.$user_id.'/feed', 'POST', array_merge($user_token, $content));
echo 'Successfully posted to Facebook';
} catch(Exception $e) {
echo $e->getMessage();
}
sleep(10);
try {
$ret = $fb->api('/'.$group_id.'/feed', 'POST', array_merge($user_token, $content));
echo 'Successfully posted to Facebook';
} catch(Exception $e) {
echo $e->getMessage();
}
sleep(10);
foreach ($share_topic['targets'] as $value) {
try {
$ret = $fb->api('/'.$value.'/feed', 'POST', array_merge($user_token, $content));
echo 'Successfully posted to Facebook';
} catch(Exception $e) {
echo $e->getMessage();
}
sleep(25);
}
$share_topic["count"] = $share_topic["count"] -1;
$sql = 'UPDATE queue SET count = '.$share_topic['count'].' WHERE url = ' . $share_topic['url'];
if($conn->query($sql) === false) : trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR); endif;
}
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.12 , 8.0.14 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Warning: require_once(): open_basedir restriction in effect. File(sdk/facebook.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/6sWhL on line 7
Warning: require_once(sdk/facebook.php): Failed to open stream: Operation not permitted in /in/6sWhL on line 7
Fatal error: Uncaught Error: Failed opening required 'sdk/facebook.php' (include_path='.:') in /in/6sWhL:7
Stack trace:
#0 {main}
thrown in /in/6sWhL on line 7
Process exited with code 255 . Output for 8.0.13 Warning: require_once(sdk/facebook.php): Failed to open stream: No such file or directory in /in/6sWhL on line 7
Fatal error: Uncaught Error: Failed opening required 'sdk/facebook.php' (include_path='.:') in /in/6sWhL:7
Stack trace:
#0 {main}
thrown in /in/6sWhL on line 7
Process exited with code 255 . Output for 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.10 , 7.3.32 - 7.3.33 , 7.4.33 Warning: require_once(sdk/facebook.php): failed to open stream: No such file or directory in /in/6sWhL on line 7
Fatal error: require_once(): Failed opening required 'sdk/facebook.php' (include_path='.:') in /in/6sWhL on line 7
Process exited with code 255 . Output for 7.1.25 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.31 , 7.4.0 - 7.4.32 Warning: require_once(): open_basedir restriction in effect. File(sdk/facebook.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/6sWhL on line 7
Warning: require_once(sdk/facebook.php): failed to open stream: Operation not permitted in /in/6sWhL on line 7
Fatal error: require_once(): Failed opening required 'sdk/facebook.php' (include_path='.:') in /in/6sWhL on line 7
Process exited with code 255 . preferences:dark mode live preview
229.71 ms | 402 KiB | 344 Q