|
 |
|
จากโค๊ดที่ผมทำเนี้ย ไม่ทราบว่าต้องแก้ตรงไหนครับ คนอื่นสามารถที่จะดูข้อมูลที่ผมใส่ได้ครับ |
|
 |
|
|
 |
 |
|
การทำ Facebook Graph Api - Posting
ไม่ทราบว่าต้องไปแก้จุดไหนครับในโค๊ดนี้ คือผมทำให้อัพขึ้น fanpage ได้แล้ว แต่ปัญหาคือ คนอื่นไม่ทราบที่จะดูข้อมูลที่ผมอัพได้ นอกจากผมคนเดียวครับ กำลังหัดใช้ครับ
ขอบคุณครับ
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<textarea name="message" id="message" cols="45" rows="5"></textarea>
<br />
<input type="text" name="link" id="link" />
<input type="submit" name="Submit" id="Submit" value="Submit" />
</form>
<?php
$msg = $_POST['message'];
$lnk = $_POST['link'];
if($msg != "" and $lnk != "")
{
/**
* Edit the Page ID you are targeting
* And the message for your fans!
*/
$page_id = '210318209151660';
$message = $msg;
$link000 = $lnk;
/**
* This code is just a snippet of the example.php script
* from the PHP-SDK <http://github.com/facebook/php-sdk/blob/master/examples/example.php>
*/
require_once('libs/facebook.php');
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => '376089662536613',
'secret' => '2bfceea34bed0dc58510010799a6b56d',
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
$page_info = $facebook->api("/$page_id?fields=access_token");
if( !empty($page_info['access_token']) ) {
$args = array(
'access_token' => $page_info['access_token'],
'message' => $message,
'link' => $link000
);
$post_id = $facebook->api("/$page_id/feed","post",$args);
} else {
$permissions = $facebook->api("/me/permissions");
if( !array_key_exists('publish_stream', $permissions['data'][0]) ||
!array_key_exists('manage_pages', $permissions['data'][0])) {
// We don't have one of the permissions
// Alert the admin or ask for the permission!
header( "Location: " . $facebook->getLoginUrl(array("scope" => "publish_stream, manage_pages")) );
}
}
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl(array('scope'=>'manage_pages,publish_stream'));
}
// ... rest of your code
echo 'Sucsess Full !';
}else
{
echo 'Not sucsess';
}
?>
Tag : Java, MySQL, HTML/CSS, Ajax, jQuery

|
|
 |
 |
 |
 |
Date :
2013-12-17 13:40:25 |
By :
Mr.mee |
View :
664 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มีคำตอบเลยหรอครับ 
|
 |
 |
 |
 |
Date :
2013-12-18 13:53:58 |
By :
Mr.mee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|