友達のニュース フィードを読んで、メッセージが表示されているかどうか (メッセージが表示されているか、非表示になっているか、削除されているかは関係ありません) を確認し、メッセージが存在する場合は、新しいメッセージを投稿しないようにしています。そこにない場合は、メッセージを投稿してください。以下のコードには、問題の原因を追跡するための多くの不要なコードが含まれています。「publish_stream, read_stream」にパーミッションを設定しました。
他のブログのすべてのコードを試しましたが、うまくいかないようでした。PHP SDK 3.0 - 最新バージョンを使用しているためかどうかはわかりません。私のアプリは iframe アプリです。Facebook アプリケーションで高価な (高すぎる) 本を購入したことさえありますが、購入後、それが古くなっていることがわかりました。
/me または自分のユーザー ID を使用しているが、友人の ID を使用していない場合、コードはうまく機能します。
require 'config.php';
require 'facebook.php';
//Create facebook application instance.
$facebook = new Facebook(array(
'appId' => $fb_app_id,
'secret' => $fb_secret
));
$sent = false;
$userData = null;
$PPnotposted = true;
$me = null;
$test_friends =1;
$user = $facebook->getUser();
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl(array("next"=> "<? echo $fb_app_url ?>" ));
} else {
$loginUrl = $facebook->getLoginUrl( array( 'scope'=> 'publish_stream, read_stream', 'redirect_uri' => $fb_app_url));
}
$get_someone_else = 100000xxxxxxxxx; // I used a real user id but covered it up here so
my friend's id hidden for this stackexchange help
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
if ( $get_someone_else ){
$user_profile = $facebook->api("/".$get_someone_else);
echo "<br/> ********************user is ".$get_someone_else." ******************<br/>";
var_dump( $user_profile );
echo "<br/> ********************** end of user info ******************<br/>";
} else {
$user_profile = $facebook->api('/me');
}
} catch (FacebookApiException $e) {
}
// print_r( $user_profile );
$PPaccesstoken = $facebook->getAccessToken();
$attachment[access_token]= $PPaccesstoken ;
//post message to wall if it is sent through form
if(isset($_POST['PPmessage'])){
try {
if( $get_someone_else ){
$ppmy_news = $facebook->api("/.$get_someone_else./feed?limit=300"); //Get 300 messages to examine
echo "<br/> *********************** news feed is ".$ppmy_news." ******************<br/>";
var_dump( $ppmy_news );
echo "<br/> ******************** end of user info ********************<br/>";
} else {
$ppmy_news = $facebook->api('/me/feed?limit=300'); //Get 300 messages
//to examine. Initially I set it to
// 10 messages for testing purposes.
}
// var_dump( $ppmy_news);
// $sent = $facebook->api("/".$user."/feed", 'POST', $attachment );
$ppmy_view_lp=0;
if( $test_friends ) { //Debugging flag to activate or deactivate parts of code
echo "sent is :<br />";
// var_dump( $sent );
echo "<br />";
$friends = $facebook->api('/me/friends');
echo "friends is :<br />";
// var_dump( $friends );
echo "<br />";
$friendsLists = $facebook->api('/me/friends');
$total_friends = 0;
foreach ($friendsLists as $friends) {
foreach ($friends as $friend) {
$id = $friend['id'];
$name = $friend['name'];
$total_friends++; //Get total number of friends
echo "friend : ".$name." id is: ".$id." Total friends is : ".$total_friends." <br/> ";
}
}
}
} catch (FacebookApiException $e) {
echo "<br/> !!!!!!!!!!!! Error Dump Line 85 !!!!!!!!!!!!! <br/>";
var_dump( $e );
echo "<br/> !!!!!!!!!!!! End of Error Dump !!!!!!!!!!!!! <br/>";
//do something about it
}
}
}
しかし、許可が拒否されていることがわかり、キャッチダンプは次のとおりです。
!!!!!!!!!!!! エラー ダンプ ライン 85 !!!!!!!!!!!!! object(FacebookApiException)#2 (7) { ["result:protected"]=> array(1) { ["error"]=> array(3) { ["message"]=> string(72) "(# 803) 要求したエイリアスの一部が存在しません: .100000xxxxxxxxx." ["type"]=> string(14) "OAuthException" ["code"]=> int(803) } } ["message:protected"]=> string(72) "(#803) いくつかのエイリアス要求されたものが存在しません: .100000xxxxxxxxx." ["string:private"]=> string(0) "" ["code:protected"]=> int(0) ["file:protected"]=> string(48) "/home/www/drpetersnews.com /vmt/base_facebook.php" ["line:protected"]=> int(1106) ["trace:private"]=> array(4) { [0]=> array(6) { ["file"]= > string(48) "/home/www/drpetersnews.com/vmt/base_facebook.php" ["line"]=> int(810) ["function"]=> string(17) "throwAPIException" ["class"] => string(12) "BaseFacebook" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> array(1) { ["error" ]=> array(3) { ["メッセージ"]=> string(72) "(#803) 要求したエイリアスの一部が存在しません: .100000xxxxxxxxx." ["type"]=> string(14) "OAuthException" ["code"]=> int(803) } } } [1]=> array(4) { ["function"]=> string(6) "_graph" ["class"]=> string(12) "BaseFacebook" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string (32)「/. 文字列(6) "_graph" } [1]=> 配列(1) { [0]=> 文字列(32) "/.100000xxxxxxxxx./feed?limit=10" } } } [3]=> 配列(6 ) { ["ファイル"]=> 文字列(40) "/home/www/drpetersnews.com/vmt/index.php" ["行"]=> int(54) ["関数"]=> 文字列(3 ) "api" ["class"]=> string(12) "BaseFacebook" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(32) "/.100000xxxxxxxxx./feed?limit=10" } } } !!!!!!!!!!!! エラーダンプ終了!!!!!!!!!!!!! 文字列(6) "_graph" } [1]=> 配列(1) { [0]=> 文字列(32) "/.100000xxxxxxxxx./feed?limit=10" } } } [3]=> 配列(6 ) { ["ファイル"]=> 文字列(40) "/home/www/drpetersnews.com/vmt/index.php" ["行"]=> int(54) ["関数"]=> 文字列(3 ) "api" ["class"]=> string(12) "BaseFacebook" ["type"]=> string(2) "->" ["args"]=> array(1) { [0]=> string(32) "/.100000xxxxxxxxx./feed?limit=10" } } } !!!!!!!!!!!! エラーダンプ終了!!!!!!!!!!!!!
許可を間違って設定したかどうか、および適切に設定する方法を教えてください。