<?php
// Remember to copy files from the SDK's src/ directory to a
// directory in your application on the server, such as php-sdk/
require_once('facebook-php-sdk-master/src/facebook.php');
echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
echo "<title> แชร์ไปที่ Facebook </title>";
$config = array(
'appId' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'fileUpload' => true,
'allowSignedRequest' => false // optional but should be set to false for non-canvas apps
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
$photo = "เว็บไดเรคเทอรี่ที่รูภาพอยู่www.web.com/xxx.jpg"; // Path to the photo on the local filesystem
$message = 'ข้อความที่ติดไปด้วยแชร์จากเว็บของฉันนะะะะะะะะะะะะ';
?>
<html>
<head></head>
<body>
<?php
if($user_id) {
// We have a user ID, so probably a logged in user.
// If not, we'll get an exception, which we handle below.
try {
// Upload to a user's profile. The photo will be in the
// first album in the profile. You can also upload to
// a specific album by using /ALBUM_ID as the path
$ret_obj = $facebook->api('/me/photos', 'POST', array(
//'source' => new CURLFile($photo, 'image/png'),
'source' => class_exists('CurlFile', false) ? new CURLFile($photo, 'image/png') : "@{$photo}" ,
'message' => $message,
)
);
echo "แชร์รูปภาพไปยัง Facebook ของท่านสำเร็จ ";
?>
<script>
var count=7;
var counter=setInterval(timer, 1000); //1000 will run it every 1 second
function timer()
{
count=count-1;
if (count <= 0)
{
self.close();
}
document.getElementById("timer").innerHTML=count + " วินาที"; // watch for spelling
}
</script>
<span id="timer">close </span>
<?
//echo '<br /><a href="' . $facebook->getLogoutUrl() . '">logout</a>';
} catch(FacebookApiException $e) {
// If the user is logged out, you can have a
// user ID even though the access token is invalid.
// In this case, we'll get an exception, so we'll
// just ask the user to login again here.
$login_url = $facebook->getLoginUrl( array(
'scope' => 'photo_upload'
));
echo ' <a href="' . $login_url . '">ยืนยันการแชร์ไปยัง Facebook ของคุณ จริงๆแล้วตรงนี้มันต้องเขียนว่า login ';
error_log($e->getType());
error_log($e->getMessage());
}
} else {
// No user, print a link for the user to login
// To upload a photo to a user's wall, we need photo_upload permission
// We'll use the current URL as the redirect_uri, so we don't
// need to specify it here.
$login_url = $facebook->getLoginUrl( array( 'scope' => 'photo_upload') );
echo ' <a href="' . $login_url . '">
ยืนยันการแชร์ไปยัง Facebook ของคุณ จริงๆแล้วตรงนี้มันต้องเขียนว่า login ';
}
?>
</body>
</html>
มันขึ้นข้อความแบบนี้อะครับ: The following permissions have not been approved for use and are not being shown to people using your app: publish_actions.Submit them for review or learn more.