첫 번째 페이스 북 앱 프로젝트에 완전히 좌절했습니다. 간단한 작업 인 것처럼 큰 문제가 있습니다.Facebook : 페이지에 페이지 올리기 (액세스 토큰/PHP)
페이스 북 페이지 (내 프로필 아님)에 뭔가 똑똑하게 게시 할 내 서버 (쉽게)에 크론 작업을 설정하고 페이지로 게시해야합니다. 나는 구석에 몸을 담글었고 지금은 완전히 혼란 스럽다. 아무도 도와 줄 수 있니? ". OAuthException : 오류 검증하는 응용 프로그램"->이 가져옵니다
첫번째 PHP가
내가 거의 모든 오류 메시지를 통해 봤는데 지금 에 부착하고 여기에
내가 지금 가지고있는 무엇 내 페이지 액세스를위한 새 액세스 토큰. 다음 페이지를 호출하고 새 액세스 토큰을받을 때이 부분은 정상적으로 작동하는 것 같습니다.
<?php
require_once 'facebook.php';
$app_id = "1234....";
$app_secret = "5678....";
$my_url = "http://.../next.php";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
// known valid access token stored in a database
$access_token = "abc....";
$code = $_REQUEST["code"];
// If we get a code, it means that we have re-authed the user
//and can get a valid access_token.
if (isset($code)) {
$token_url="https://graph.facebook.com/oauth/access_token?
client_id="
. $app_id . "&redirect_uri=" . urlencode($my_url)
. "&client_secret=" . $app_secret
. "&code=" . $code . "&display=popup";
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$access_token = $params['access_token'];
}
// Attempt to query the graph:
$graph_url = "https://graph.facebook.com/me?"
. "access_token=" . $access_token;
$response = curl_get_file_contents($graph_url);
$decoded_response = json_decode($response);
//Check for errors
if ($decoded_response->error) {
// check to see if this is an oAuth error:
if ($decoded_response->error->type== "OAuthException") {
// Retrieving a valid access token.
$dialog_url= "https://www.facebook.com/dialog/oauth?"
. "client_id=" . $app_id
. "&redirect_uri=" . urlencode($my_url);
echo("<script> top.location.href='" . $dialog_url
. "'</script>");
} else {
echo "other error has happened";
}
} else {
// success
echo("success" . $decoded_response->name);
}
function curl_get_file_contents($URL) {
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
$err = curl_getinfo($c,CURLINFO_HTTP_CODE);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
}
?>
다음 php -> 액세스 토큰을 읽고 벽에 게시하십시오. 내 쿼리 문자열에서 액세스 토큰을 얻을 수 있지만 다음 오류 메시지가 나타납니다. 내 아이디, 비밀 페이지 ID는 내가 그렇게 할 수있는 간단한 방법이 있는지 해요 .... 및 방법은 실제로 작동하도록
<?php
require_once 'facebook.php';
$app_id = "1234....";
$app_secret = "5678....";
$page_id = "0909....";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$access_token = $_GET['code'];
echo($access_token);
try {
$attachment = array(
'access_token' => $access_token,
'message'=> "Hello World"
);
$result = $facebook->api('/'.$page_id.'/feed','POST',
$attachment);
var_dump($result);
} catch(Exception $e) {
echo $e;
}
?>
... 위해 모두! 도움을 주시면 감사하겠습니다.
나는이 스크립트 Update facebook page status from that page itself 을 따라이 https://developers.facebook.com/blog/post/500감사합니다.
내가 어디 http://stackoverflow.com/questions/4309154/update-facebook- 같은 페이지 액세스 토큰을 추출하는에 관해서 (안 PHP 자신을 dev에) 코드에 불분명 해요 page-status-that-page-itself-graph-api-php는 않습니다. – DMCS
첫 번째 스크립트에서 액세스 토큰을 얻고 있습니다. 링크 된 예제에서 얻은 액세스 토큰을 사용할 때 토큰은 2 시간 동안 제한되기 때문입니다. 첫 번째 스크립트는 이전 액세스 토큰을 확인합니다 -> 이전 버전임을 인식하고 쿼리 문자열에 새 스크립트를 반환합니다 ... – Peter1178373