-
Notifications
You must be signed in to change notification settings - Fork 0
/
final.php
108 lines (94 loc) · 3.35 KB
/
final.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/********************************************************************************************************************
Made By-Abhishek Raj
*********************************************************************************************************************/
?>
<?php
/*************************************************************************************************************************/
session_start();
require_once("autoload.php");
//Facebook PHP SDK
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;
use Facebook\FacebookSession;
//App Access Token
$AppID = app_ID;
$AppToken = app_secret_token;
//Page Access Token
$pageAccessToken = page_access_token;
$config = FacebookSession::setDefaultApplication($AppID, $AppToken); //Configuration of the app
$facebookSession = new FacebookSession($pageAccessToken); //Facebook Session Object
$userID = user_id; //Facebook User ID i.e. Abhishek Raj
$pageID = page_id; //Facebook Page ID
$message = ''; //Main message to post
//Configuration of the Connection Complete
/*************************************************************************************************************************/
?>
<?php
/*************************************************************************************************************************/
//Server side CAPTCHA configuration
require_once('recaptchalib.php');
$privatekey = captcha_private_key; //CAPTCHA private key
if($_POST)
{
$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
//Response of the CAPTCHA test
if (!$resp->is_valid)
{
//CATCHA test failed
$message = $_POST['status']; //Set message to the input message for easy access
echo "CAPTCHA incorrect. Try again.";
}
else
{//Start of Else
/*************************************************************************************************************************/
?>
<?php
/*************************************************************************************************************************/
//Checking if status is already given
if(isset($_POST['status']))
{
$message = $_POST['status'];
$args = array(
'message' => $message
);
//Message formation complete
$facebookRequest = new FacebookRequest($facebookSession , 'POST', "/$pageID/feed", $args); //Facebook Request Object
$post = $facebookRequest->execute()->getGraphObject(); //Actual Posting.
$postID = $post->getProperty('id');
echo "<a target='_blank' href='http://facebook.com/$postID'>Posted. Goto Status.$postID</a><br>"; //Link to the status
}
/************************************************************************************************************************/
?>
<?php
//End of Else
}
}
?>
<html>
<head>
<title>
Hello World
</title>
</head>
<body>
<h1>Hello World</h1>
<hr>
<!--The actual form for posting the status-->
<form method="post" id="sendStatus">
<label>Message: </label><br>
<textarea name="status" cols="60" rows="5"><?php echo $message;?></textarea><br>
<!--CAPTCHA client side-->
<?php
require_once('recaptchalib.php');
$publickey = public_key; //Public key of CAPTCHA
echo recaptcha_get_html($publickey);
?>
<!--CAPTCHA client side over-->
<input class="submit" type="submit" value="Post">
</form>
<!--Form complete-->
<hr>
</body>
</html>