|
 |
|
App Facebook ติดปัญหาตอนอัพรูปเข้าอัลบั้มแล้วต้อง Approve Photo ก่อน |
|
 |
|
|
 |
 |
|
พอดีว่าผมกำลังศึกษาการพัฒนาแอพของเฟสบุ๊คให้แฟนอยู่ครับ
ทำเกี่ยวกับความงาม เล่นแอพบนหน้าแฟนเพจ แต่ทีนี้ติดปัญหาส่วนเดียวคือ
ตอนที่สร้างอัลบั้มแล้วให้สุ่มภาพและอัพโหลดรูปเข้าไป
ปกติคือรูปจะอัพเข้าและโพสต์ในหน้า wall ให้อัตโนมัติ แต่ของผมคือ
ติดตรงที่มันจะขึ้น Approve Photo ทุกครั้งที่เล่น ถ้ากดถึงจะแสดงใน wall
ประมาณนี้ครับ ภาพด้านล่าง

โค้ดหน้าแรกครับ คือให้กด Like ที่ Fanpage ก่อน ถึงจะเล่นเกมส์ได้
Code
<?PHP
require '../src/facebook.php';
$app_id = '246671572074184';
$app_secret = 'bf956918c4aa83404a0b76f3da8a2750';
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$signed_request = $facebook->getSignedRequest();
$page_id = $signed_request["page"]["id"];
$page_admin = $signed_request["page"]["admin"];
$like_status = $signed_request["page"]["liked"];
$country = $signed_request["user"]["country"];
$locale = $signed_request["user"]["locale"];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<?PHP
if(!$like_status)
{
echo '<img src="../images/non-like.png" border="0" />';
echo '<a href="play-app.php">เล่มเกมส์</a>';
}
else
{
echo 'กดไลท์แล้ว';
$user = $facebook->getUser();
if($user)
{
try
{
$user_profile = $facebook->api('/me');
}
catch(FacebookApiException $e)
{
$user = null;
}
}
if($user)
{
echo 'ลงทะเบียนแล้ว<hr>';
echo 'เริ่มเล่นเกมส์กับเรา';
echo '<a href="play-app.php">เล่มเกมส์</a>';
}
else
{
echo 'ยังไม่ได้ลงทะเบียน';
echo '<script>top.location.href="'.$facebook->getLoginUrl().'"</script>';
}
}
?>
</div>
</body>
</html>
โค้ดหน้าที่ให้อัพรูปเข้าไปในอัลบั้มครับ
Code
<?PHP
require '../src/facebook.php';
$app_id = '246671572074184';
$app_secret = 'bf956918c4aa83404a0b76f3da8a2750';
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true,
'fileUpload' => true
));
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<?PHP
$albumName = 'ชื่ออัลบั้ม';
$albumMessage = 'คำอธิบายอัลบั้ม';
$args_album=array( // ค่าที่ส่งไปด้วย
"name"=>$albumName, // ชื่อ album ที่ต้องการกำหนด
"message"=>$albumMessage // คำอธิบายเกี่ยวกับ album
);
try{
if($albumName!=""){ // ตรวจสอบถ้ามีการกำหนดชื่อมา
$create_album = $facebook->api("/me/albums","post", $args_album); // สร้าง album ใหม่
$album_id = $create_album['id'];
}
}catch (FacebookApiException $o) {
// pre($o);
error_log($o);
}
$full_image_path = '../images/bg.jpg';
$full_image_path = realpath($full_image_path);
$args = array(
'message' => 'มาดามเม้าส์ขอเม้นท์ว่าคุุณคือ...', // คำอธิบายรูปภาพ
//'source'=> '@' . realpath($imgs) // ไฟล์รูปภาพ
'source' => '@' . $full_image_path
);
try{
// ให้ทำการอัพโหลดรูปภาพไปยัง album ที่่เลือก
$facebook -> api("/".$album_id."/photos","post", $args);
}catch (FacebookApiException $o) {
// pre($o);
error_log($o);
}
?>
</div>
</body>
</html>
Tag : PHP, HTML/CSS, JavaScript, Action Script, Ajax, jQuery

|
|
 |
 |
 |
 |
Date :
2012-03-01 08:54:14 |
By :
lovetummy |
View :
1684 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เคยเจอใน facebook ถ้าหาเจอจะกลับมาตอบให้
|
 |
 |
 |
 |
Date :
2012-09-30 17:48:19 |
By :
.... |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|