Code:
<?php
/* FB App System, version 2.0
copyright 2010-2011, FBappSystem.com
For Personal Use Only:
You may install it on your domain only.
You MAY NOT install it on pages and domains not owned by you, or pass it to others for their use.
Unauthorized duplication, distribution or use are STRICTLY FORBIDDEN and are punishable by U.S. and international law. */
//This section of code manage the database calls
include ("config.php");
mysql_connect($db_host, $db_user, $db_pwd) or die("cannot connect");
mysql_select_db($db_name) or die("cannot select DB");
///This section insert the userinfo
if (isset ($_REQUEST['email'])) {
$Email = $_REQUEST['email'];
$facebookid = $_REQUEST['fid'];
$name = $_REQUEST['name'];
$gender = $_REQUEST['sex'];
$bdate = $_REQUEST['bdate'];
$city = $_REQUEST['city'];
$state = $_REQUEST['state'];
$country = $_REQUEST['country'];
$sql = "select facebookid from facebookdata where facebookid =" . $facebookid . " and appid='" . $appid . "'";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) {
echo '1';
}
else {
$sql = "INSERT INTO `facebookdata` (`facebookid`, `email`, `name`, `gender`,`birthday`, `state`, `city`, `country`, `appid`) VALUES
('$facebookid', '$Email', '$name', '$gender','$bdate', '$city', '$state','$country','$appid')";
$result = mysql_query($sql);
echo 'new';
$sql = "select * from wallsettings where appid='" . $appid . "'";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result)) {
echo $row['description'];
echo $returnurl;
PostToAweber($_REQUEST['name'], $_REQUEST['email'], $aweberlistid);
posttowall($_REQUEST['accesstoken'], $row['description'], $facebookid, $returnurl,$row['name'], $row['caption'], $row['picture']);
}
}
}
}
//This function is used to post to wall of the user
function posttowall($token, $desc, $uid, $linkurl,$linkname, $message, $imgurl) {
$attachment = array('access_token' => $token, 'name' => $linkname, 'link' => $linkurl, 'description' => $desc, 'caption' => $message, 'picture' => $imgurl);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/' . $uid . '/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);
echo $result;
}
/////This function is used to put the user email in the aweber
function PostToAweber($name, $email, $aweberlistid) {
$post_data['listname'] = $aweberlistid;
$post_data['redirect'] = 'http://' . $_SERVER['HTTP_HOST'];
$post_data['name'] = $name;
$post_data['email'] = $email;
$post_data['meta_adtracking'] = 'custom form';
$post_data['meta_message'] = '1';
$post_data['meta_required'] = 'name,email';
$post_data['meta_forward_vars'] = '1';
foreach ($post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}
$post_string = implode('&', $post_items);
$curl_connection = curl_init('www.aweber.com/scripts/addlead.pl');
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
$result = curl_exec($curl_connection);
print_r($result);
curl_close($curl_connection);
}
?>
$db_host, $db_user, $db_pwd is all managed by config
Bookmarks