|
 |
|
facebook sdk php เวลาโพสขึ้น feed ไม่ขึ้น (สถานะ) ขึ้นแต่ (เฉพาะฉัน) มีวิธีแก้ไขไหมคับ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
session_start(); //Session should be active
include_once '/facebook-php-sdk-v4-4.0-dev/autoload.php';
require_once( '/facebook-php-sdk-v4-4.0-dev/src/Facebook/FacebookSession.php' );
$redirect_url='http://localhost/facebook/';
use Facebook\FacebookRequest;
use Facebook\FacebookRequestException;
use Facebook\FacebookSession;
use Facebook\GraphUser;
use Facebook\FacebookRedirectLoginHelper;
FacebookSession::setDefaultApplication('APP ID', 'Secret ID');
FacebookSession::enableAppSecretProof(false);
$helper = new FacebookRedirectLoginHelper($redirect_url);
//try to get current user session
try {
$session = $helper->getSessionFromRedirect();
} catch(FacebookRequestException $ex) {
die(" Error : " . $ex->getMessage());
} catch(\Exception $ex) {
die(" Error : " . $ex->getMessage());
}
if($session) {
// Login ผ่าน
try {
$response = (new FacebookRequest(
$session, 'POST', '/me/photos', array(
'source' => new CURLFile(__DIR__ . '/photo.jpg', 'image/jpeg'),
'message' => 'ทดสอบ Upload Photo โดยใช้ Facebook SDK'
)
))->execute()->getGraphObject();
echo "Posted with id: " . $response->getProperty('id');
} catch(FacebookRequestException $e) {
echo "Exception occured, code: " . $e->getCode();
echo " with message: " . $e->getMessage();
}
// echo 'OK !!';
}else{
// Login ไม่ผ่าน
//display login url
$login_url = $helper->getLoginUrl( array( 'scope' => $required_scope ) );
echo '<a href="'.$login_url.'">Login with Facebook</a>';
}
?>
ขึ้นเห็นเฉพาะฉัน ไม่เห็นได้ทุกคน มีวิธีทำให้โพสขึ้นไปแล้ว ทุกคนเห็น ไหมครับ
Tag : PHP, HTML/CSS, Action Script, Ajax, CakePHP

|
|
 |
 |
 |
 |
Date :
2015-08-31 03:32:09 |
By :
ilikeit |
View :
1052 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 01
|