GVKun编程网logo

php – facebook扩展权限(facebook选择php)

9

想了解php–facebook扩展权限的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于facebook选择php的相关问题,此外,我们还将为您介绍关于#import"facebookSDK/

想了解php – facebook扩展权限的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于facebook选择php的相关问题,此外,我们还将为您介绍关于#import "facebookSDK/FacebookSDK.h file not found"、android – 使用Facebook应用程序打开Facebook Url、com.facebook.android.Facebook的实例源码、com.facebook.FacebookActivity的实例源码的新知识。

本文目录一览:

php – facebook扩展权限(facebook选择php)

php – facebook扩展权限(facebook选择php)

更新2:

好的,通过改变它“有点”工作:

$loginUrl = $facebook->getLoginUrl(array(
           'canvas' => 1,
           'fbconnect' => 0,
           'req_perms' => 'publish_stream',
           'next' => 'http://'.$_SERVER['SERVER_NAME'].'/success.PHP',
           'cancel_url' => 'http://'.$_SERVER['SERVER_NAME'].'/cancel.PHP'
        ));

对此:

$loginUrl = $facebook->getLoginUrl(array(
           'canvas' => 1,
           'fbconnect' => 0,
           'req_perms' => 'publish_stream',
           'next' => 'http://'.$_SERVER['SERVER_NAME'].'/success.PHP',
           'cancel_url' => 'http://'.$_SERVER['SERVER_NAME'].'/cancel.PHP'
        ));
        header('Location: '.$loginUrl);

即我添加了标题(‘Location:’.$loginUrl);.

但页面表现得很奇怪.我必须导航到页面,登录,然后刷新页面,再次登录,然后它会要求我允许发布到页面,并最终发布到页面.

为什么我要登录两次?

更新1:

我现在有以下脚本似乎不起作用.在这种状态下,我只是想张贴到自己的墙上,但最终也想发布到朋友的墙上:

<?PHP
    /**
     *
     * copyright 2011 Facebook, Inc.
     *
     * Licensed under the Apache License, Version 2.0 (the "License"); you may
     * not use this file except in compliance with the License. You may obtain
     * a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     * License for the specific language governing permissions and limitations
     * under the License.
     */


    require 'facebook.PHP';

    // Create our Application instance (replace this with your appId and secret).
    $facebook = new Facebook(array(
        'appId'  => '<appId removed for security reasons>',
        'secret' => '<secret removed for security reasons>',
        'cookie' => true,
    ));

    // We may or may not have this data based on a $_GET or $_COOKIE based session.
    //
    // If we get a session here, it means we found a correctly signed session using
    // the Application Secret only Facebook and the Application kNow. We dont kNow
    // if it is still valid until we make an API call using the session. A session
    // can become invalid if it has already expired (should not be getting the
    // session back in this case) or if the user logged out of Facebook.
    $session = $facebook->getSession();

    $me = null;
    // Session based API call.
    if ($session) {
        try {
            $uid = $facebook->getUser();
            $me = $facebook->api('/me');

            $post = $facebook->api("/me/Feed", "POST",  array('message' => 'Hello! I\'m using the FB Graph API!'));
        } catch (FacebookApiException $e) {
            error_log($e);
        }
    }

    // login or logout url will be needed depending on current user state.
    if ($me) {
        $logoutUrl = $facebook->getlogoutUrl();
    } else {
        $loginUrl = $facebook->getLoginUrl(array(
           'canvas' => 1,
           'fbconnect' => 0,
           'req_perms' => 'publish_stream',
           'next' => 'http://'.$_SERVER['SERVER_NAME'].'/success.PHP',
           'cancel_url' => 'http://'.$_SERVER['SERVER_NAME'].'/cancel.PHP'
        ));
    }

?>

<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
        <title>PHP-sdk</title>

        <style>
            body {
                font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
            }

            h1 a {
                text-decoration: none;
                color: #3b5998;
            }

            h1 a:hover {
                text-decoration: underline;
            }
        </style>
    </head>

    <body>
    <!--
        We use the JS SDK to provide a richer user experience. For more info,
        look here: http://github.com/facebook/connect-js
    -->
        <div id="fb-root"></div>
        <script>
        window.fbAsyncInit = function() {
            FB.init({
                appId   : '<?PHP echo $facebook->getAppId(); ?>',
                session : <?PHP echo json_encode($session); ?>, // don't refetch the session when PHP already has it
                status  : true, // check login status
                cookie  : true, // enable cookies to allow the server to access the session
                xfbml   : true // parse XFBML
            });

            // whenever the user logs in, we refresh the page
            FB.Event.subscribe('auth.login', function() {
                window.location.reload();
            });
        };

        (function() {
            var e = document.createElement('script');
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            e.async = true;
            document.getElementById('fb-root').appendChild(e);
        }());
    </script>


    <h1><a href="example.PHP">PHP-sdk</a></h1>

    <?PHP if ($me): ?>
        <a href="<?PHP echo $logoutUrl; ?>">
            <img src="http://static.ak.fbcdn.net/rsrc.PHP/z2Y31/hash/cxrz4k7j.gif">
        </a>
    <?PHP else: ?>
        <div>
            Using JavaScript &amp; XFBML: <fb:login-button></fb:login-button>
        </div>
    <?PHP endif ?>

    <h3>Session</h3>
    <?PHP if ($me): ?>
        <pre><?PHP print_r($session); ?></pre>

        <h3>You</h3>
        <img src="https://graph.facebook.com/<?PHP echo $uid; ?>/picture">
        <?PHP echo $me['name']; ?>

        <h3>Your User Object</h3>
        <pre><?PHP print_r($me); ?></pre>
    <?PHP else: ?>
        <strong><em>You are not Connected.</em></strong>
    <?PHP endif ?>
  </body>
</html>

我收到以下错误:

[Wed Apr 27 22:28:16 2011] [error] [client <ip address removed for security reasons>] OAuthException: (#200) The user hasn't authorized the application to perform this action, referer: http://<ip address removed for security reasons>/index.PHP

原始问卷:

我有以下工作脚本,允许有人使用他们的Facebook详细信息登录我的页面,然后我可以捕获他们的access_token,所以我可以使用它与图形api:

<?PHP
    /**
     *
     * copyright 2011 Facebook, Inc.
     *
     * Licensed under the Apache License, Version 2.0 (the "License"); you may
     * not use this file except in compliance with the License. You may obtain
     * a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     * License for the specific language governing permissions and limitations
     * under the License.
     */


    require 'facebook.PHP';

    // Create our Application instance (replace this with your appId and secret).
    $facebook = new Facebook(array(
        'appId'  => 'app id goes here',
        'secret' => 'secret id goes here',
        'cookie' => true,
    ));

    // We may or may not have this data based on a $_GET or $_COOKIE based session.
    //
    // If we get a session here, it means we found a correctly signed session using
    // the Application Secret only Facebook and the Application kNow. We dont kNow
    // if it is still valid until we make an API call using the session. A session
    // can become invalid if it has already expired (should not be getting the
    // session back in this case) or if the user logged out of Facebook.
    $session = $facebook->getSession();

    $me = null;
    // Session based API call.
    if ($session) {
        try {
            $uid = $facebook->getUser();
            $me = $facebook->api('/me');
        } catch (FacebookApiException $e) {
            error_log($e);
        }
    }

    // login or logout url will be needed depending on current user state.
    if ($me) {
        $logoutUrl = $facebook->getlogoutUrl();
    } else {
        $loginUrl = $facebook->getLoginUrl();
    }

?>

<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
        <title>PHP-sdk</title>

        <style>
            body {
                font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
            }

            h1 a {
                text-decoration: none;
                color: #3b5998;
            }

            h1 a:hover {
                text-decoration: underline;
            }
        </style>
    </head>

    <body>
    <!--
        We use the JS SDK to provide a richer user experience. For more info,
        look here: http://github.com/facebook/connect-js
    -->
        <div id="fb-root"></div>
        <script>
        window.fbAsyncInit = function() {
            FB.init({
                appId   : '<?PHP echo $facebook->getAppId(); ?>',
                session : <?PHP echo json_encode($session); ?>, // don't refetch the session when PHP already has it
                status  : true, // check login status
                cookie  : true, // enable cookies to allow the server to access the session
                xfbml   : true // parse XFBML
            });

            // whenever the user logs in, we refresh the page
            FB.Event.subscribe('auth.login', function() {
                window.location.reload();
            });
        };

        (function() {
            var e = document.createElement('script');
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            e.async = true;
            document.getElementById('fb-root').appendChild(e);
        }());
    </script>


    <h1><a href="example.PHP">PHP-sdk</a></h1>

    <?PHP if ($me): ?>
        <a href="<?PHP echo $logoutUrl; ?>">
            <img src="http://static.ak.fbcdn.net/rsrc.PHP/z2Y31/hash/cxrz4k7j.gif">
        </a>
    <?PHP else: ?>
        <div>
            Using JavaScript &amp; XFBML: <fb:login-button></fb:login-button>
        </div>
    <?PHP endif ?>

    <h3>Session</h3>
    <?PHP if ($me): ?>
        <pre><?PHP print_r($session); ?></pre>

        <h3>You</h3>
        <img src="https://graph.facebook.com/<?PHP echo $uid; ?>/picture">
        <?PHP echo $me['name']; ?>

        <h3>Your User Object</h3>
        <pre><?PHP print_r($me); ?></pre>
    <?PHP else: ?>
        <strong><em>You are not Connected.</em></strong>
    <?PHP endif ?>
  </body>
</html>

用户登录后,我了解到我可以通过以下方式获取他们的朋友列表:

https://graph.facebook.com/me/friends?access_token=...

我无法弄清楚如何使用扩展权限,所以我的应用程序可以发布给用户朋友的Facebook墙.

显然我应该使用扩展的权限加上以下内容:

curl -F 'access_token=...' \
     -F 'message=Hello, Arjun. I like this new API.' \
     https://graph.facebook.com/arjun/Feed

我不明白我应该如何从PHP做到这一点.

解决方法:

更新:

好吧,我自己无法真正测试它,所以只需要一些建议就可以尝试.将$loginUrl更改为:

$loginUrl = $facebook->getLoginUrl(array(
    'req_perms' => 'publish_stream',
    'next' => 'http://'.$_SERVER['SERVER_NAME'].'/success.PHP',
    'cancel_url' => 'http://'.$_SERVER['SERVER_NAME'].'/cancel.PHP'
));

在整个上下文中,文件的顶部应如下所示:

require 'facebook.PHP';

$facebook = new Facebook(array(
    'appId' => '<appId removed for security reasons>',
    'secret' => '<secret removed for security reasons>',
    'cookie' => true,
));

$session = $facebook->getSession();

$me = null;
if ($session)
{
   try
   {
       $uid = $facebook->getUser();
       $me = $facebook->api('/me');

       $post = $facebook->api("/me/Feed", "POST", array('message' => 'Hello! I\'m using the FB Graph API!'));
   }
   catch (FacebookApiException $e)
   {
      error_log($e);
   }
}
else
{
$loginUrl = $facebook->getLoginUrl(array(
        'req_perms' => 'publish_stream',
        'next' => 'http://' . $_SERVER['SERVER_NAME'] . '/success.PHP',
        'cancel_url' => 'http://' . $_SERVER['SERVER_NAME'] . '/cancel.PHP'
   ));
   header('Location: ' . $loginUrl);
}

那么,首先检查您是否有会话,因此您需要像示例中那样配置Facebook SDK:

$facebook = new Facebook(array(
    'appId'  => 'app id goes here',
    'secret' => 'secret id goes here',
    'cookie' => true,
));

然后,您可以检查用户是否已登录并且您的应用已获得授权:

if ($facebook->getSession() == null) {
   // not logged in or not authorized
}

在if子句中,您必须重定向到正确的login-url以获得所需的所有权限:

$loginUrl = $facebook->getLoginUrl(array(
   'canvas' => 1,
   'fbconnect' => 0,
   'req_perms' => 'publish_stream',
   'next' => // url where to go when you were authorized
   'cancel_url' => // url to go to when user cancelled
));
header('Location: '.$loginUrl);

获得权限后,您可以使用在文档中提到的发布

$facebook->api(/* url */, array(/* additional parameters go here */));

#import <FacebookSDK/FacebookSDK.h>

#import "facebookSDK/FacebookSDK.h file not found"

第一种可能: 从window下上传到mac 下 facebook sdk出错!【这个是系统的错误,只能从其他地方拷贝 FacebookSDK.framework 文件夹 就ok】,下图是正常状态,【不正常的状态下,这几个文件直接是物理文件了】

第二种可能 ,设置读取路径错误


在mac下 project下找到build setting ,再找 searchPath,点击Framework search paths 设置路径即可

"$(SRCROOT)/xxx/xxx/FacebookSDK.framework"

android – 使用Facebook应用程序打开Facebook Url

android – 使用Facebook应用程序打开Facebook Url

我想从我的 Android应用程序打开一个Facebook链接.
URL看起来像 http://www.facebbok.com/abcxyz.它应该在Facebook应用程序中打开’abcxyz’页面,但它总是在浏览器中打开.

码:

try 
{
    Intent browserIntent = new Intent(Intent.ACTION_VIEW,Uri.parse(url));
    activityContext.startActivity(browserIntent);
} 
catch (ActivityNotFoundException ex) 
{
     ex.printstacktrace();
}

我的Android操作系统版本是6.0.1.

我和Instagram,http://www.instagram.com/abcxyz有同样的问题,而Youtube等其他应用程序也有问题.

解决方法

您应该使用Facebook的自定义网址方案强制应用打开您的页面,如下所示:
public Intent getFacebookIntent(String url) {

  PackageManager pm = context.getPackageManager();
  Uri uri = Uri.parse(url);

  try {
    ApplicationInfo applicationInfo = pm.getApplicationInfo("com.facebook.katana",0);
    if (applicationInfo.enabled) {
      uri = Uri.parse("fb://facewebmodal/f?href=" + url);
    }
  }  

  catch (PackageManager.NameNotFoundException ignored) {
  }

  return new Intent(Intent.ACTION_VIEW,uri);
}

com.facebook.android.Facebook的实例源码

com.facebook.android.Facebook的实例源码

项目:SevenWonders    文件:LoginAndGetPermissions.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    //ALog.m();

    super.onCreate(savedInstanceState);

    mFacebook = new Facebook();

       if ( mFacebook.isSessionValid() ) {
        //ALog.i("Already have a saved Facebook session,skipping authorization.");

        setResult(RESULT_OK);
        finish();
        return;
       }        

       mFacebook.authorize(this,FacebookConfig.getAppId(),PERMISSIONS,new LoginDialogListener());
    //setContentView(R.layout.facebook);
   }
项目:foursquared    文件:AddFriendsByUserInputActivity.java   
private void startFacebookWebViewActivity() {
    Intent intent = new Intent(this,FacebookWebViewActivity.class);
    intent.putExtra(FacebookWebViewActivity.INTENT_EXTRA_ACTION,Facebook.LOGIN);
    intent.putExtra(FacebookWebViewActivity.INTENT_EXTRA_KEY_APP_ID,getResources().getString(R.string.facebook_api_key));
    intent.putExtra(FacebookWebViewActivity.INTENT_EXTRA_KEY_PERMISSIONS,new String[] {}); //{"publish_stream","read_stream","offline_access"});
    intent.putExtra(FacebookWebViewActivity.INTENT_EXTRA_KEY_DEBUG,false);
    intent.putExtra(FacebookWebViewActivity.INTENT_EXTRA_KEY_CLEAR_COOKIES,true);
    startActivityForResult(intent,ACTIVITY_RESULT_FACEBOOK_WEBVIEW_ACTIVITY);
}
项目:foursquared    文件:AddFriendsByUserInputActivity.java   
/**
 * Listen for FacebookWebViewActivity finishing,inspect success/failure and returned
 * request parameters.
 */
@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data) {
    if (requestCode == ACTIVITY_RESULT_FACEBOOK_WEBVIEW_ACTIVITY) {
        // If RESULT_OK,means the request was attempted,but we still have to check the return status.
        if (resultCode == RESULT_OK) {
            // Check return status.
            if (data.getBooleanExtra(FacebookWebViewActivity.INTENT_RESULT_KEY_RESULT_STATUS,false)) {

                // If ok,the result bundle will contain all data from the webview.
                Bundle bundle = data.getBundleExtra(FacebookWebViewActivity.INTENT_RESULT_KEY_RESULT_BUNDLE);

                // We can switch on the action here,the activity echoes it back to us for convenience.
                String suppliedAction = data.getStringExtra(FacebookWebViewActivity.INTENT_RESULT_KEY_SUPPLIED_ACTION);
                if (suppliedAction.equals(Facebook.LOGIN)) {
                    // We can Now start a task to fetch foursquare friends using their facebook id.
                    mStateHolder.startTaskFindFriends(
                            AddFriendsByUserInputActivity.this,bundle.getString(Facebook.TOKEN));
                }
            } else {
                // Error running the operation,report to user perhaps.
                String error = data.getStringExtra(FacebookWebViewActivity.INTENT_RESULT_KEY_ERROR);
                Log.e(TAG,error);
                Toast.makeText(this,error,Toast.LENGTH_LONG).show();
                finish();
            }
        } else {
            // If the user cancelled enterting their facebook credentials,exit here too.
            finish();
        }
    }
}
项目:Socialite    文件:SharedPreferencesCredentialStore.java   
public static void clearFacebookCredentials(Facebook facebook,Context context) {   
    if(facebook.isSessionValid())
        facebook.getSession().close();
    Editor editor = context.getSharedPreferences(FACEBOOK_KEY,Context.MODE_PRIVATE).edit();
    editor.remove(FACEBOOK_TOKEN);
    editor.commit();
}
项目:Socialite    文件:FacebookConnector.java   
public FacebookConnector(String appId,String[] permissions,SocialActivity socialActivity) {

        this.facebook = new Facebook(appId);
        SharedPreferencesCredentialStore.restoreFacebookSession(facebook,socialActivity.getApplicationContext());
        this.permissions=permissions;
        this.mHandler = new Handler();
        this.activity = socialActivity;
        socialActivity.registerSocialConnector(this);

    }
项目:Socialite    文件:FacebookConnector.java   
public FacebookConnector(String appId,SocialSliderActivity socialActivity) {

        this.facebook = new Facebook(appId);
        SharedPreferencesCredentialStore.restoreFacebookSession(facebook,socialActivity.getApplicationContext());
        this.permissions=permissions;
        this.mHandler = new Handler();
        this.activity = socialActivity;
        socialActivity.registerSocialConnector(this);

    }
项目:kaorisan    文件:ShareFacebookActivity.java   
public void shareFacebook(){
    facebook = new Facebook("1418005058449444");
    restoreCredentials(facebook);
    messagetoPost = "Hello Everyone.";
    if (!facebook.isSessionValid()) {
        loginAndPostToWall();
    } else {
        postToWall(messagetoPost);
    }
}
项目:SevenWonders    文件:SessionStore.java   
public static boolean save(Facebook session,Context context) {
    Editor editor =
        context.getSharedPreferences(KEY,Context.MODE_PRIVATE).edit();
    editor.putString(TOKEN,session.getAccesstoken());
    editor.putLong(EXPIRES,session.getAccessExpires());
    return editor.commit();
}
项目:SevenWonders    文件:SessionStore.java   
public static boolean restore(Facebook session,Context context) {
    SharedPreferences savedSession =
        context.getSharedPreferences(KEY,Context.MODE_PRIVATE);
    session.setAccesstoken(savedSession.getString(TOKEN,null));
    session.setAccessExpires(savedSession.getLong(EXPIRES,0));
    return session.isSessionValid();
}
项目:SevenWonders    文件:FacebookApplicationPost.java   
private void makeWallPost() {
    //ALog.m();

    Facebook facebook = new Facebook();      
    SessionStore.restore(facebook,this);

    //ALog.i("stream.publish parameters: ",mParams);
    facebook.dialog(FacebookApplicationPost.this,"stream.publish",mParams,new WallPostDialogListener());  
}
项目:haxsync    文件:FacebookUtil.java   
@Override
public void onComplete(Bundle values) {
    //Log.i("got values",values.toString());
    accesstoken = values.getString(Facebook.TOKEN);
    // Todo Auto-generated method stub

}
项目:facebook-android-sdk    文件:Tests.java   
public boolean testPublicApi() {
    Facebook fb = new Facebook(APP_ID);
    try {
        Log.d("Tests","Testing standard API call");
        JSONObject response = Util.parseJson(fb.request("4"));
        if (!response.getString("name").equals("Mark Zuckerberg")) {
            return false;
        }

        Log.d("Tests","Testing an API call with a specific method");
        response = Util.parseJson(
                fb.request("soneff",new Bundle(),"GET"));
        if (!response.getString("name").equals("Steven Soneff")) {
            return false;
        }

        Log.d("Tests","Testing a public search query");
        Bundle params = new Bundle();
        params.putString("q","facebook");
        response = Util.parseJson(fb.request("search",params));
        if (response.getJSONArray("data").length() == 0) return false;

        Log.d("Tests","Public API Tests passed"); 
        return true;
    } catch (Throwable e) {
        e.printstacktrace();
        return false;
    }
}
项目:Socialite    文件:SharedPreferencesCredentialStore.java   
public static boolean restoreFacebookSession(Facebook facebook,Context context) {  
    SharedPreferences savedSession = context.getSharedPreferences(FACEBOOK_KEY,Context.MODE_PRIVATE);
    facebook.setAccesstoken(savedSession.getString(FACEBOOK_TOKEN,null));
    facebook.setAccessExpires(savedSession.getLong(EXPIRES,0));
    return facebook.isSessionValid();
}
项目:Socialite    文件:SharedPreferencesCredentialStore.java   
public static boolean saveFacebookToken(Facebook session,Context context) {
    Editor editor = context.getSharedPreferences(FACEBOOK_KEY,Context.MODE_PRIVATE).edit();
    editor.putString(FACEBOOK_TOKEN,session.getAccessExpires());
    return editor.commit();
}
项目:Socialite    文件:FacebookConnector.java   
public void forceAuthenticate() {
    facebook.authorize(this.activity,this.permissions,Facebook.FORCE_DIALOG_AUTH,new LoginDialogListener());
}
项目:Socialite    文件:FacebookConnector.java   
public Facebook getFacebook() {
    return this.facebook;
}
项目:kaorisan    文件:ShareFacebookActivity.java   
public boolean saveCredentials(Facebook facebook) {
    Editor editor = getApplicationContext().getSharedPreferences(KEY,facebook.getAccesstoken());
    editor.putLong(EXPIRES,facebook.getAccessExpires());
    return editor.commit();
}
项目:kaorisan    文件:ShareFacebookActivity.java   
public boolean restoreCredentials(Facebook facebook) {
    SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(KEY,Context.MODE_PRIVATE);
    facebook.setAccesstoken(sharedPreferences.getString(TOKEN,null));
    facebook.setAccessExpires(sharedPreferences.getLong(EXPIRES,0));
    return facebook.isSessionValid();
}
项目:kaorisan    文件:ShareFacebookActivity.java   
public void loginAndPostToWall() {
    facebook.authorize(this,new LoginDialogListener());
}
项目:kaorisan    文件:LoginActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    loginActivity = this;
    sqliteDatabaseAdapter.setContext(this);

    checkGooglePlayServices();

    mPlusClient = new PlusClient.Builder(this,this,this)
    .setVisibleActivities("http://schemas.google.com/AddActivity","http://schemas.google.com/BuyActivity").setScopes(Scopes.PLUS_LOGIN,Scopes.PLUS_PROFILE).build();

    btnLoginGoogle = (Button) findViewById(R.id.btn_login_google);
    initGoogleButton();

    genKeyHash();
    resource = getResources();

    DebugLog.logd("On create");

    // Create the Facebook Object using the app id.
    if (Utility.mFacebook == null) {
        Utility.mFacebook = new Facebook(APP_ID);
    }
    // Instantiate the asynrunner object for asynchronous api calls.
    if (Utility.mAsyncRunner == null) {
        Utility.mAsyncRunner = new AsyncFacebookRunner(Utility.mFacebook);
    }

    SessionStore.restore(Utility.mFacebook,this);

    SessionEvents.addAuthListener(authenListener);
    SessionEvents.addlogoutListener(logoutListener);

    Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);

    btnLoginFaceBook = (Button) findViewById(R.id.btn_login_facebook);
    initFacebookButton();

    SessionEvents.addAuthListener(mSessionListener);
    SessionEvents.addlogoutListener(mSessionListener);

    if (Utility.mFacebook.isSessionValid() && islogout == 0 && currentSocial == Social.FACEBOOK) {
        DebugLog.logd("On facebook Create");
        if (Utils.checkInternetConnect(this)) {
            requestGetUserData();
        }
    }

    if (currentSocial == Social.GOOGLE && islogout == 0) {
        DebugLog.logd("On Google Create");
        mPlusClient.connect();
    }
    checklogout();

}
项目:haxsync    文件:AuthorizationActivity.java   
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.main);
    String[] permissions = {"offline_access","user_events","friends_events","friends_status","user_status","friends_photos","user_photos","friends_about_me","friends_website","email","friends_birthday","friends_location"};
    FacebookUtil.facebook.authorize(AuthorizationActivity.this,permissions,new DialogListener() {
        @Override
        public void onComplete(Bundle values) {
            FacebookUtil.accesstoken = FacebookUtil.facebook.getAccesstoken();
            Log.i("Expires",String.valueOf(FacebookUtil.facebook.getAccessExpires()));;
            AccountManager am = AccountManager.get(AuthorizationActivity.this);
            Account account = am.getAccountsByType(AuthorizationActivity.this.getString(R.string.ACCOUNT_TYPE))[0];
            am.setPassword(account,FacebookUtil.facebook.getAccesstoken());
            SharedPreferences prefs = AuthorizationActivity.this.getSharedPreferences(AuthorizationActivity.this.getPackageName() + "_preferences",MODE_MULTI_PROCESS);
            SharedPreferences.Editor editor = prefs.edit();
            editor.putInt("permission_level",FacebookUtil.PERMISSION_LEVEL);
            editor.putLong("access_expires",FacebookUtil.facebook.getAccessExpires());
            editor.commit();
            ContentResolver.requestSync(account,ContactsContract.AUTHORITY,new Bundle());
            ContentResolver.requestSync(account,CalendarContract.AUTHORITY,new Bundle());
        //  Log.i(TAG,ContentResolver.);
            //Log.i(TAG,"Calendar :" + ContentResolver.isSyncActive(account,CalendarContract.AUTHORITY));
        //  Log.i(TAG,"Contacts :" + ContentResolver.isSyncActive(account,ContactsContract.AUTHORITY));
            FacebookUtil.isExtendingToken = false;
            AuthorizationActivity.this.finish();
        }

        @Override
        public void onFacebookError(FacebookError error) {
            Log.i(TAG,"fberror");
            AuthorizationActivity.this.finish();
        }

        @Override
        public void onError(DialogError e) {
            Log.i(TAG,"error");
            AuthorizationActivity.this.finish();
        }

        @Override
        public void onCancel() {
            Log.i(TAG,"cancel");
            AuthorizationActivity.this.finish();
        }
    });
}
项目:IPRJapp    文件:Tutorial_1.java   
@SuppressWarnings("deprecation")
@Override
   public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);        

        if (savedInstanceState != null)

            TutoRes = savedInstanceState.getInt("TutoRes");
        facebook = new Facebook(APP_ID);
        AsyncFacebookRunner   mAsyncRunner = new AsyncFacebookRunner(facebook);
        //loginFacebook();

requestwindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.tutorial_1);
//setLogin();



Session.openActiveSession(this,true,new Session.StatusCallback() {


    @Override
    public void call(final Session session,SessionState state,Exception exception) {
        if (session.isOpened()) {

            Request.newMeRequest(session,new Request.GraphUserCallback() {

                  @Override
                  public void onCompleted(GraphUser user,Response response) {

                      if (user != null) {

                        //welcome = (TextView) findViewById(R.id.welcome);                      
                        Userid = user.getId();
                        User_name= user.getFirstName();


                        }
                  }
                }).executeAsync();
            }
    }
  }); 



final Button  Button = (Button) findViewById(R.id.button1);

Button.setonClickListener(new View.OnClickListener() {

       @Override
      public void onClick(View v) {

        if(Userid != null && User_name != null){

             Intent intent = new Intent();
             intent.setClass(Tutorial_1.this,Tutorial_2.class);
             db.addUsuario(new Usuario(User_name,Userid));
            startActivity(intent);
             finish();


        }

        else {

            Toast.makeText(getApplicationContext(),"Aguarde o carregamento dos dados do perfil do Facebook",Toast.LENGTH_SHORT).show();

        }

       }

});
   }

com.facebook.FacebookActivity的实例源码

com.facebook.FacebookActivity的实例源码

项目:kognitivo    文件:DialogPresenter.java   
public static void setupAppCallForErrorResult(AppCall appCall,FacebookException exception) {
    if (exception == null) {
        return;
    }
    Validate.hasFacebookActivity(FacebookSdk.getApplicationContext());

    Intent errorResultIntent = new Intent();
    errorResultIntent.setClass(FacebookSdk.getApplicationContext(),FacebookActivity.class);
    errorResultIntent.setAction(FacebookActivity.PASS_THROUGH_CANCEL_ACTION);

    NativeProtocol.setupProtocolRequestIntent(
            errorResultIntent,appCall.getCallId().toString(),null,NativeProtocol.getLatestKNownVersion(),NativeProtocol.createBundleForException(exception));

    appCall.setRequestIntent(errorResultIntent);
}
项目:kognitivo    文件:DialogPresenter.java   
public static void setupAppCallForWebDialog(
        AppCall appCall,String actionName,Bundle parameters) {
    Validate.hasFacebookActivity(FacebookSdk.getApplicationContext());
    Validate.hasInternetPermissions(FacebookSdk.getApplicationContext());

    Bundle intentParameters = new Bundle();
    intentParameters.putString(NativeProtocol.WEB_DIALOG_ACTION,actionName);
    intentParameters.putBundle(NativeProtocol.WEB_DIALOG_ParaMS,parameters);

    Intent webDialogIntent = new Intent();
    NativeProtocol.setupProtocolRequestIntent(
            webDialogIntent,actionName,intentParameters);
    webDialogIntent.setClass(FacebookSdk.getApplicationContext(),FacebookActivity.class);
    webDialogIntent.setAction(FacebookDialogFragment.TAG);

    appCall.setRequestIntent(webDialogIntent);
}
项目:kognitivo    文件:Validate.java   
public static void hasFacebookActivity(Context context,boolean shouldThrow) {
    Validate.notNull(context,"context");
    PackageManager pm = context.getPackageManager();
    ActivityInfo activityInfo = null;
    if (pm != null) {
        ComponentName componentName =
                new ComponentName(context,FacebookActivity.class);
        try {
            activityInfo = pm.getActivityInfo(componentName,PackageManager.GET_ACTIVITIES);
        } catch (PackageManager.NameNotFoundException e) {
        }
    }
    if (activityInfo == null) {
        if (shouldThrow) {
            throw new IllegalStateException(FACEBOOK_ACTIVITY_NOT_FOUND_REASON);
        } else {
            Log.w(TAG,FACEBOOK_ACTIVITY_NOT_FOUND_REASON);
        }
    }
}
项目:Move-Alarm_ORCA    文件:DialogPresenter.java   
public static void setupAppCallForErrorResult(AppCall appCall,FacebookException exception) {
    if (exception == null) {
        return;
    }

    Intent errorResultIntent = new Intent();
    errorResultIntent.setClass(FacebookSdk.getApplicationContext(),NativeProtocol.createBundleForException(exception));

    appCall.setRequestIntent(errorResultIntent);
}
项目:Move-Alarm_ORCA    文件:DialogPresenter.java   
public static void setupAppCallForWebDialog(
        AppCall appCall,Bundle parameters) {
    Bundle intentParameters = new Bundle();
    intentParameters.putString(NativeProtocol.WEB_DIALOG_ACTION,FacebookActivity.class);
    webDialogIntent.setAction(FacebookDialogFragment.TAG);

    appCall.setRequestIntent(webDialogIntent);
}
项目:SocioBlood    文件:DialogPresenter.java   
public static void setupAppCallForErrorResult(AppCall appCall,NativeProtocol.createBundleForException(exception));

    appCall.setRequestIntent(errorResultIntent);
}
项目:SocioBlood    文件:DialogPresenter.java   
public static void setupAppCallForWebDialog(
        AppCall appCall,FacebookActivity.class);
    webDialogIntent.setAction(FacebookDialogFragment.TAG);

    appCall.setRequestIntent(webDialogIntent);
}
项目:SocioBlood    文件:Validate.java   
public static void hasFacebookActivity(Context context,FACEBOOK_ACTIVITY_NOT_FOUND_REASON);
        }
    }
}
项目:kognitivo    文件:LoginManager.java   
private Intent getFacebookActivityIntent(LoginClient.Request request) {
    Intent intent = new Intent();
    intent.setClass(FacebookSdk.getApplicationContext(),FacebookActivity.class);
    intent.setAction(request.getLoginBehavior().toString());

    // Let FacebookActivity populate extras appropriately
    LoginClient.Request authClientRequest = request;
    Bundle extras = new Bundle();
    extras.putParcelable(LoginFragment.EXTRA_REQUEST,request);
    intent.putExtras(extras);

    return intent;
}
项目:androidadvanced    文件:RecipeListActivityTest.java   
@Test
public void testRecyclerViewFBShareClicked_ShouldStartFBActivity() throws Exception {
    int positionToClick = 0;
    setUpShadowAdapter(positionToClick);

    shadowAdapter.itemVisible(positionToClick);
    shadowAdapter.performItemClickOverViewInHolder(positionToClick,R.id.fbShare);

    Intent intent = shadowActivity.peekNextStartedActivity();
    assertEquals(new ComponentName(RuntimeEnvironment.application,FacebookActivity.class),intent.getComponent());
}
项目:androidadvanced    文件:RecipeListActivityTest.java   
@Test
public void testRecyclerViewFBSendClicked_ShouldStartFBActivity() throws Exception {
    int positionToClick = 0;
    setUpShadowAdapter(positionToClick);

    shadowAdapter.itemVisible(positionToClick);
    shadowAdapter.performItemClickOverViewInHolder(positionToClick,R.id.fbSend);

    Intent intent = shadowActivity.peekNextStartedActivity();
    assertEquals(new ComponentName(RuntimeEnvironment.application,intent.getComponent());
}
项目:Move-Alarm_ORCA    文件:LoginManager.java   
private Intent getLoginActivityIntent(LoginClient.Request request) {
    Intent intent = new Intent();
    intent.setClass(FacebookSdk.getApplicationContext(),FacebookActivity.class);
    intent.setAction(request.getLoginBehavior().toString());

    // Let LoginActivity populate extras appropriately
    LoginClient.Request authClientRequest = request;
    Bundle extras = LoginFragment.populateIntentExtras(authClientRequest);
    intent.putExtras(extras);

    return intent;
}
项目:SocioBlood    文件:LoginManager.java   
private Intent getFacebookActivityIntent(LoginClient.Request request) {
    Intent intent = new Intent();
    intent.setClass(FacebookSdk.getApplicationContext(),FacebookActivity.class);
    intent.setAction(request.getLoginBehavior().toString());

    // Let FacebookActivity populate extras appropriately
    LoginClient.Request authClientRequest = request;
    Bundle extras = LoginFragment.populateIntentExtras(authClientRequest);
    intent.putExtras(extras);

    return intent;
}
项目:kognitivo    文件:DialogPresenter.java   
public static void setupAppCallForWebFallbackDialog(
        AppCall appCall,Bundle parameters,DialogFeature feature) {
    Validate.hasFacebookActivity(FacebookSdk.getApplicationContext());
    Validate.hasInternetPermissions(FacebookSdk.getApplicationContext());

    String featureName = feature.name();
    Uri fallbackUrl = getDialogWebFallbackUri(feature);
    if (fallbackUrl == null) {
        throw new FacebookException(
                "Unable to fetch the Url for the DialogFeature : '" + featureName + "'");
    }

    // Since we're talking to the server here,let's use the latest version we kNow about.
    // We kNow we are going to be communicating over a bucketed protocol.
    int protocolVersion = NativeProtocol.getLatestKNownVersion();
    Bundle webParams = ServerProtocol.getQueryParamsForPlatformActivityIntentWebFallback(
            appCall.getCallId().toString(),protocolVersion,parameters);
    if (webParams == null) {
        throw new FacebookException("Unable to fetch the app's key-hash");
    }

    // Now form the Uri
    if (fallbackUrl.isRelative()) {
        fallbackUrl = Utility.buildUri(
                ServerProtocol.getDialogAuthority(),fallbackUrl.toString(),webParams);
    } else {
        fallbackUrl = Utility.buildUri(
                fallbackUrl.getAuthority(),fallbackUrl.getPath(),webParams);
    }

    Bundle intentParameters = new Bundle();
    intentParameters.putString(NativeProtocol.WEB_DIALOG_URL,fallbackUrl.toString());
    intentParameters.putBoolean(NativeProtocol.WEB_DIALOG_IS_FALLBACK,true);

    Intent webDialogIntent = new Intent();
    NativeProtocol.setupProtocolRequestIntent(
            webDialogIntent,feature.getAction(),FacebookActivity.class);
    webDialogIntent.setAction(FacebookDialogFragment.TAG);

    appCall.setRequestIntent(webDialogIntent);
}
项目:Move-Alarm_ORCA    文件:DialogPresenter.java   
public static void setupAppCallForWebFallbackDialog(
        AppCall appCall,DialogFeature feature) {
    String featureName = feature.name();
    Uri fallbackUrl = getDialogWebFallbackUri(feature);
    if (fallbackUrl == null) {
        throw new FacebookException(
                "Unable to fetch the Url for the DialogFeature : '" + featureName + "'");
    }

    // Since we're talking to the server here,FacebookActivity.class);
    webDialogIntent.setAction(FacebookDialogFragment.TAG);

    appCall.setRequestIntent(webDialogIntent);
}
项目:SocioBlood    文件:DialogPresenter.java   
public static void setupAppCallForWebFallbackDialog(
        AppCall appCall,FacebookActivity.class);
    webDialogIntent.setAction(FacebookDialogFragment.TAG);

    appCall.setRequestIntent(webDialogIntent);
}

今天关于php – facebook扩展权限facebook选择php的讲解已经结束,谢谢您的阅读,如果想了解更多关于#import "facebookSDK/FacebookSDK.h file not found"、android – 使用Facebook应用程序打开Facebook Url、com.facebook.android.Facebook的实例源码、com.facebook.FacebookActivity的实例源码的相关知识,请在本站搜索。

本文标签: