Hi! I have a Facebook app which uses PHP and JS SDK. JS for the like button and PHP for passing infromation. It's not displying well in different browsers. Say in safari it's displaying but not in Chrome and Firefox. I have cleared my cache and cookies but still getting the same problem. How can i fix this? Is it fine to combine the two SDK's? wouldn't affect the browser behavior? thanks!
karen.frias0316 0 Newbie Poster
Edited by pritaeas because: Moved to Web Development.
LastMitch
How can i fix this? Is it fine to combine the two SDK's? wouldn't affect the browser behavior? thanks!
@karen.frias0316
There is more involve than what you just explain.
Please post your code.
karen.frias0316 0 Newbie Poster
@LastMitch hi here it is. I used PHP SDK in logging in and posting link to user's timeline. then JS SDK for the like button in my gallery page. Like button is working well as well as share button. but my posting to timeline is not. below is my code. thanks for any help.
processor. php
require_once('libs/facebook.php');
$facebook = new Facebook(array(
'appId' => 'xxxxxx',
'secret' => 'xxxxxxx'
));
Some code herefor processing user input and saving to database
//save inputs to db
//save inputs to db
if (!empty($name) && !empty($email) && !empty($office_id) && !empty($title) && !empty($story)) {
$save_sql = "INSERT INTO `tbl_contest` (filename, name, email, office_id, title, story, time) VALUES ('$img_newname','$name','$email','$office_id','$title','$story','$sql_date')";
$query = mysql_query($save_sql,$con) or die(mysql_error("Could not write information to the database"));
if (mysql_num_rows($con) !== 0) {
// get user UID
$fb_user_id = $facebook->getUser();
// get the url where to redirect the user
$location = "". $facebook->getLoginUrl(array('scope' => 'publish_stream'));
// check if we have valid user
if ($fb_user_id) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$fb_user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
$fb_user_id = NULL;
print '<script language="javascript" type="text/javascript"> top.location.href="'. $location .'"; </script>';
die();
}
} else {
print '<script language="javascript" type="text/javascript"> top.location.href="'. $location .'"; </script>';
die();
}
$ret_obj = $facebook->api('/me/feed', 'POST',
array(
'link' => $post_link,
'message' => $post_msg
));
}
header('Location:' . $uploadSuccess.'#modal-text');
mysqli_close($con);
}
here's the gallery.php
$con = mysql_connect('localhost', 'user', 'password');
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$selected = mysql_select_db("db_name",$con) or die(mysql_error());
//perform query on while.
$count = 0;
$image_query = mysql_query ("SELECT filename, story FROM tbl_test ORDER BY time DESC") or die(mysql_error());
while($image_data = mysql_fetch_array($image_query)){
$imageName = stripslashes(mysql_real_escape_string($image_data['filename']));
$count++;
echo '<div class="outer_cont">';
echo '<div class="imagecontainer"><a href="http://birdieonawire.com/Folder/image_entry/'.$imageName.'" rel="prettyPhoto[gallery1]"><img class="images" src="http://birdieonawire.com/Folder/image_entry/'.$imageName.'"'.$count.' /></a></div><div class="details"><div class="fb-like" data-href="http://birdieonawire.com/Folder/image_entry/'.$imageName.'" data-colorscheme="light" data-layout="button_count" data-action="like" data-show-faces="true" data-send="false"></div> <br /> <div class="share"><a href="https://www.facebook.com/sharer/sharer.php?u=http://birdieonawire.com/Folder/image_entry/'.$imageName.'" target="_blank"><img src="images/share.jpg" /></a></div></div></div>';
}
Edited by karen.frias0316
karen.frias0316 0 Newbie Poster
$con = mysql_connect('localhost', 'user', 'password');
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$selected = mysql_select_db("db_name",$con) or die(mysql_error());
//perform query on while.
$count = 0;
$image_query = mysql_query ("SELECT filename, story FROM tbl_test ORDER BY time DESC") or die(mysql_error());
while($image_data = mysql_fetch_array($image_query)){
$imageName = stripslashes(mysql_real_escape_string($image_data['filename']));
$count++;
echo '<div class="outer_cont">';
echo '<div class="imagecontainer"><a href="http://birdieonawire.com/Folder/image_entry/'.$imageName.'" rel="prettyPhoto[gallery1]"><img class="images" src="http://birdieonawire.com/Folder/image_entry/'.$imageName.'"'.$count.' /></a></div><div class="details"><div class="fb-like" data-href="http://birdieonawire.com/Folder/image_entry/'.$imageName.'" data-colorscheme="light" data-layout="button_count" data-action="like" data-show-faces="true" data-send="false"></div> <br /> <div class="share"><a href="https://www.facebook.com/sharer/sharer.php?u=http://birdieonawire.com/Folder/image_entry/'.$imageName.'" target="_blank"><img src="images/share.jpg" /></a></div></div></div>';
}
LastMitch
Like button is working well as well as share button. but my posting to timeline is not. below is my code. thanks for any help.
@karen.frias0316
There's nothing seem wrong with the code you provided.
Rather than javascript issue, I'm leaning towards a CSS issue.
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.