簡體   English   中英

使用圖形API在朋友的牆上發布

[英]posting on a friend's wall using graph API

在朋友的牆上發布消息,圖API。 我有使用該應用程序的用戶的publish_stream擴展權限。

如果我想在我的牆上張貼,代碼就會工作。

是否有任何方法可以在牆上發布或向特定用戶的所有朋友發送消息?

請幫忙謝謝!!

以下是代碼,但它不起作用。

 $friends = $facebook->api('/me/friends');
    foreach($friends['data'] as $friend){
            $friendsUserId = $friend['id'];
            echo $friendsUserId . "</br>";
            $result = $facebook->api('/$friendsUserId/feed', 'POST', array(                
                    message' => 'Test Message'                ));
            print_r($result);
        }

這可能是這樣做的方式..(未經測試,但我對我的應用程序使用類似的東西。)

$friends = $facebook->api('/me/friends');

    foreach($friends['data'] as $friend) {
        $facebook->api('/$friend['id']/feed', 'post', array(
                  'message' => 'just a test message',
                  'link' => 'http://site.com',
                  'name' => 'just a test name',
                  'caption' => 'just a test caption',
                  'description' => 'just a test description',
          ));

}

這是使用PHP API

我只是進行了一些測試,並且擁有用戶的權限,我確實可以通過php api在用戶的朋友牆上發布:

$facebook->api('/[FRIEND_ID]/feed', 'post', array(
          'message' => 'test message',
          'link' => 'http://google.com',
          'name' => 'test name',
          'caption' => 'test caption',
          'description' => 'test long description',
      ));

publish_stream權限僅允許您在特定用戶牆上發布內容 - 您無法在他所有朋友的牆上發布內容。

以這種方式考慮一下 - 比如你沒有授權申請在你的Facebook牆上發布任何內容,只是因為你的一個朋友已經訪問了他的牆 - 它自動不會讓應用程序訪問他的所有牆上的內容朋友。

編輯

Rahul,我昨天晚上嘗試以自己的身份登錄,並通過我的應用程序在我的一個朋友的牆上發布消息,令人驚訝的是它有效。 我有一種錯誤的印象,你不能這樣做。 我很抱歉。

但我仍然無法弄清楚這一點。 讓我解釋

1) I have my real facebook lets call it abc and a test facebook account xyz which I've added as my friend to abc
2) I login into my app using my abc faceboook account and publish a message on the wall of my friend xyz
3) Now I login to facebook.com as abc and it shows on my news feed the message that I published on xyz's wall. When I click on xyz's profile - the message shows up on his wall too. So far so good
4) Now I log out of facebook.com as abc and log back in as xyz. But now I dont see the message that was posted through the app on the wall of xyz.

我不知道是否有任何延遲,但我已經等了30分鍾,但仍然沒有。 但是當我以abc身份登錄時它會繼續顯示。

我希望你能理解我在這里要傳達的內容。 我使用了與你相同的代碼 - 所以你可以嘗試上面的場景,看看你是否經歷過類似的事情

謝謝

$ friends = $ facebook-> api('/ me / friends');

foreach($friends['data'] as $friend) {
    $facebook->api('/$friend['id']/feed', 'post', array(
              'message' => 'just a test message',
              'link' => 'sample link.com',
              'name' => 'just a test name',
              'caption' => 'just a test caption',
              'description' => 'just a test description',
      ));

上面的代碼為我工作tooooo謝謝你的帖子

Gubloo的答案很接近。

發布到朋友的牆上是完全可能的,但有一點需要注意,所述朋友必須在某個時候也經歷過“權限”對話。 這意味着,您的應用程序的用戶將能夠發布到您的應用程序的其他用戶的牆上。

我打算給你iPhone代碼,因為我不知道php,想象你會得到這個要點。 只需將“我”替換為您要發布的任何內容的UID,成為頁面或朋友的個人資料。

[_facebook requestWithGraphPath:@"/me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self];

我真的很想知道這是否會讓用戶能夠在任何使用該應用程序的人的牆上張貼,而不僅僅是他的朋友。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM