-1

私は単純なオンライン ゲームを作成しています。ユーザーがゲームを完了すると、Facebook でスコアを共有するように求められます。UI をあまり複雑にしたくはありません。理想的には、Twitter のつぶやきボタンのように機能し、次のような事前定義された (編集可能な) メッセージが必要です。

「mygame.com で 560 点を獲得しました」

これをユーザーの Facebook ウォールに投稿したいと思います。

コードとユーザーにとって最も簡単なオプションは何ですか? 私はphp、mysql、jquery、javascript、ajaxで働いています

4

3 に答える 3

0
    $attachment = array(
     'access_token' => $accessToken,
     'message' => $text,
     'name' => $appName,
     'link' => $appLink,
     'description' => "I have just scored 560 on mygame.com",
    );
    return $response = $facebook->api("/$fbid/feed", 'POST', $attachment);

$facebookはFacebookAPIオブジェクトです。ユーザーのウォールに投稿するには、Facebookアプリと権限を作成する必要があります。

于 2012-09-12T13:03:09.810 に答える
0

https://www.facebook.com/dialog/feed?app_id=393236134020452&link=<the url you want to share>&picture=<url of any picture you want to show in the users' status updates>&name=<title of the status update>&caption=<text of the status update>&redirect_uri=<url to redirect users upon completion of the sharing action>Facebook Javascript SDK が手元にあると仮定すると、おそらく新しいタブで にリンクするボタンを作成できます。

ご覧になりたい場合は、純粋な JS と JS SDK を使用して、ここで同様のものを作成しました。

于 2012-09-11T14:34:32.197 に答える
0

Javascript SDK を使用することをお勧めします: https://developers.facebook.com/docs/reference/javascript/

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'YOUR_APP_ID', // App ID - get one at https://developers.facebook.com/apps/
      channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });

    // Additional initialization code here - Change fields below to match what you want to share and wrap it inside a function that you trigger on click
    FB.ui({
      method: 'feed',
      name: 'Facebook Dialogs',
      link: 'https://developers.facebook.com/docs/reference/dialogs/',
      picture: 'http://fbrell.com/f8.jpg',
      caption: 'Reference Documentation',
      description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
    },function(response) {
      if (response && response.post_id) {
        alert('Post was published.');
      } else {
        alert('Post was not published.');
      }
    });
  };

  // Load the SDK Asynchronously
  (function(d){
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     ref.parentNode.insertBefore(js, ref);
   }(document));
</script>

チャネル ファイルは次のようになります。

<script src="//connect.facebook.net/en_US/all.js"></script>
于 2012-09-11T14:38:59.087 に答える