2013-02-28 10 views
19

すべてのことが可能でないと言う前に、Spotifyアプリを開き、Facebookボタンでログインしてください。1つのリクエストで読み取り権限と公開権限を取得する

私は、彼らはそれをどうやったのか思ったんだけど、どのように私は、「publish_stream」と一つのリクエストで、基本的な権限/電子メールを取得することができます。私は(彼らはアプリを使用した最後の時間を)最後のセッションから特定の情報を持っているなら、私はFacebookのSDKを使用してFacebookのセッションを再開するため

また、それは可能ですか?音楽アプリケーションのダッシュボードに

Spotify magic

+0

Spotifyの可能性は、その機能が他のすべてのアプリにも拡張されているわけではないからです。 FBから直接サードパーティのコンピュータアプリケーションを開くことができる他のアプリを知っていますか? –

+0

あなたはSpotifyがロイヤルティストリーミングの支払いを相殺するためにFacebookにピギーバックしていることを示唆しています、そして、ZuckerbergはP2Pストリーミングサービスに対する長い間愛されているためにパートナーシップを推進していますか? ...それはクレイジーです。 – baconcheese113

+0

@ Vijayの答えをチェックしてください。私はそれを編集しました。 –

答えて

20

publish_streamの結果ではありません彼らは使う。上のリンクでそれについてもっと読む。


編集説明Check the Open Graph Permissions

サンプルアクティビティー:

public class MainActivity extends Activity implements StatusCallback { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     OpenRequest open = new OpenRequest(this); 
     open.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO); 
     open.setPermissions(Arrays.asList(new String[]{"email", "publish_actions", "user_birthday", "user_hometown"})); 
     open.setCallback(this); 
     Session s = new Session(this); 
     s.openForPublish(open); 
    } 

    @Override 
    public void call(Session session, SessionState state, Exception exception) { 
    } 

    @Override 
    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     super.onActivityResult(requestCode, resultCode, data); 
     if(Session.getActiveSession()!=null) 
      Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data); 
    } 
} 

このアクティビティは、この表示されます(ユーザーがログインしていない場合):

enter image description here

+1

これは正しい答えです。 'publish_actions'権限を追加しようとします。この回答を編集してテストを追加します。 –

+0

私はちょうど同じFBログイン(pinterestのような)をパーミッションの電子メール、basic_info、publish_actionで1つのリクエストで実行しようとしています。コードの上に実装しましたが、そうすることはできません... plz help ... – sanjay

0

移動を回避FOR -SCREENSHOTS BELOW

EDIT。編集アプリをクリックします。今すぐページの左側にPermissionが表示されます。クリックして。新しいページが表示されます。詳しくはUser & Friend Permissions:箱をご覧ください。ここにはpublish_actionsと入力します。今すぐ保存してください。

は今、あなたのアンドロイドアプリからあなただけの一回のログインでのFacebookに記事を投稿することができます。つまり、LoginButtonでログインして何かを投稿しようとしています。それは動作するはずです。

私に何が起こるか教えてください。

のFacebook SDKが

if(Session.openActiveSession(this) == null) { //Haven't logged in yet 
    openSessionForRead(getString(R.string.app_id), Arrays.asList("email")); 
} 

Facebookは、トークンをキャッシュし、このコードを使用して使用してFacebookのセッションを再度開くには:私の質問の後半部分に疑問を抱いている人のため

+0

これは私のモバイルアプリでは機能していないようです。私は自分自身でセッション管理(openSessionForPublishをまだ読み込み権限を持たずに実装)と、Facebook SDKが提供しているツール(com.facebook.widget.LoginButtonと読み取りと公開権限の設定)の両方を試してみました。 両方とも同時にリクエストできないというエラーがスローされます。 – baconcheese113

+0

は読み取り権を要求するだけです。 @ baconcheese113 – Shoshi

+0

次に、読み取り権限のみを求めるプロンプトが表示されます。 openSessionForRead( "app_id"、 "permission_list") – baconcheese113

0

。使用している彼らはOpen Graph

オープングラフの概念は、アプリケーションを介してユーザーとFB活動の柱とアプリの動作を統合し、共有する関係である.What今​​まであなたが楽しんでる上で見たもの

1

私のアプリケーションでは、OpenRequest用のインスタンスを作成しており、そのためのアクセス権を設定しています。

Session currentSession = Session.getActiveSession(); 
if (currentSession == null || currentSession.getState().isClosed()) 
{ 
    Session session = new Session.Builder(context).build(); 
    Session.setActiveSession(session); 
    currentSession = session; 
} 

if (currentSession.isOpened()) 
{ 
    //Do whatever u want. User has logged in 
} 
else if(!currentSession.isOpened()) 
{ 
    //Ask for username and password 
    OpenRequest op = new Session.OpenRequest(context); 

    op.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO); 
    op.setCallback(null); 

    List<String> permissions = new ArrayList<String>(); 
    permissions.add("publish_stream"); 
    op.setPermissions(permissions); 

    Session session = new Builder(InvitePartners.this).build(); 
    Session.setActiveSession(session); 
    session.openForPublish(op); 
} 

あなたにとって役に立ちます。

1

onCreateメソッドで別途設定しました。

LoginButton authButton = (LoginButton) view.findViewById(R.id.authButton); 
    authButton.setPublishPermissions("publish_actions"); 
    authButton.setFragment(this); 
    Session.NewPermissionsRequest newPermissionsRequest = new 
      Session.NewPermissionsRequest(this, Arrays.asList("read_stream")); 
    Session.getActiveSession().requestNewReadPermissions(newPermissionsRequest); 
関連する問題