Get Read and Publish Permissions in one request

baconcheese113 picture baconcheese113 · Feb 28, 2013 · Viewed 20.1k times · Source

Before you all say it's not possible, open up the Spotify app and hit the signin with Facebook button.

I'm wondering how they did it, and how I can get "publish_stream" and basic permissions/email in one request.

Also, is it possible for me to reopen a Facebook session using the Facebook SDK if I have certain info from the last session (last time they used the app)?

EDIT -SCREENSHOTS BELOW FOR THE MUSICALLY AVERT

Spotify magic

Answer

Vijay picture Vijay · Mar 11, 2013

What ever you saw on Spotify is not the outcome of publish_stream .What they have used is the Open Graph

Open graph concepts involves integrating actions of the app with the FB activity post and share with the users through the application they use. Read more about it at the above mentioned link.


Edits Explanation: Check the Open Graph Permissions

Sample Activity:

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);
    }
}

This activity will show this (if the user is not logged in):

enter image description here