カテゴリー : Facebook

Facebook ビジネスマネージャの「広告アカウントのパートナー」機能を活用して Facebook・Instagram 広告運用代行

Facebook ビジネスマネージャの「広告アカウントのパートナー」機能を活用して Facebook・Instagram 広告運用代行を始めるための設定手順をご紹介します。

Facebook

続きを読む

Facebookビジネスマネージャのサポートチーム (CS) 問合せ方法(チャット・メール)

Facebook ビジネスマネージャのサポートチーム (CS) へチャットやメールで問合せた手順をご紹介します。

Facebook

続きを読む

Facebook Messenger のメッセージを一括エクスポートする方法

Facebook Messenger のメッセージを一括エクスポートする方法をご紹介します。

Facebook Messenger

続きを読む

[Android] Facebook SDK でエラー : Failure delivering result ResultInfo{who=null, request=64206, result=0, data=null} to activity {com.example/com.facebook.LoginActivity}: java.lang.NullPointerException

Facebook SDK for Android v3.0 でログイン処理時に NullPointerException エラーが発生しました。

Stack Trace
0	java.lang.RuntimeException: 
Failure delivering result ResultInfo{who=null, request=64206, result=0, data=null}
to activity {com.example/com.facebook.LoginActivity}: java.lang.NullPointerException
1		at android.app.ActivityThread.deliverResults(ActivityThread.java:2980)
2		at android.app.ActivityThread.handleSendResult(ActivityThread.java:3023)
3		at android.app.ActivityThread.access$1100(ActivityThread.java:123)
4		at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1177)
5		at android.os.Handler.dispatchMessage(Handler.java:99)
6		at android.os.Looper.loop(Looper.java:137)
7		at android.app.ActivityThread.main(ActivityThread.java:4424)
8		at java.lang.reflect.Method.invokeNative(Native Method)
9		at java.lang.reflect.Method.invoke(Method.java:511)
10		at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11		at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12		at dalvik.system.NativeStart.main(Native Method)
13	Caused by: java.lang.NullPointerException
14		at com.facebook.AuthorizationClient$KatanaProxyAuthHandler.onActivityResult(SourceFile:645)
15		at com.facebook.AuthorizationClient.onActivityResult(SourceFile:142)
16		at com.facebook.LoginActivity.onActivityResult(SourceFile:134)
17		at android.app.Activity.dispatchActivityResult(Activity.java:4676)
18		at android.app.ActivityThread.deliverResults(ActivityThread.java:2976)
19		... 11 more
20	java.lang.NullPointerException
21		at com.facebook.AuthorizationClient$KatanaProxyAuthHandler.onActivityResult(SourceFile:645)
22		at com.facebook.AuthorizationClient.onActivityResult(SourceFile:142)
23		at com.facebook.LoginActivity.onActivityResult(SourceFile:134)
24		at android.app.Activity.dispatchActivityResult(Activity.java:4676)
25		at android.app.ActivityThread.deliverResults(ActivityThread.java:2976)
26		at android.app.ActivityThread.handleSendResult(ActivityThread.java:3023)
27		at android.app.ActivityThread.access$1100(ActivityThread.java:123)
28		at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1177)
29		at android.os.Handler.dispatchMessage(Handler.java:99)
30		at android.os.Looper.loop(Looper.java:137)
31		at android.app.ActivityThread.main(ActivityThread.java:4424)
32		at java.lang.reflect.Method.invokeNative(Native Method)
33		at java.lang.reflect.Method.invoke(Method.java:511)
34		at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
35		at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
36		at dalvik.system.NativeStart.main(Native Method)

Facebook SDK for Android v3.0 のバグらしいので、v3.0.1 にアップデートすることで解決します。

参考情報

[Android] Facebook 認証できないエラー : com.facebook.FacebookOperationCanceledException: remote_app_id does not match stored id

Android アプリ開発で、Facebook 認証できないというエラーが発生しました。

com.facebook.FacebookOperationCanceledException: remote_app_id does not match stored id

Facebook アプリの設定画面に登録している Key Hashes が間違っている場合、このようなエラーが発生するようです。

下記のコードを onCreate に記載して、key hash をログに出力して確認します。

try {
    PackageInfo info = getPackageManager().getPackageInfo("com.example.packagename",
            PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.d("YOURHASH KEY:",
                Base64.encodeToString(md.digest(), Base64.DEFAULT));
    }
} catch (NameNotFoundException e) {
 
} catch (NoSuchAlgorithmException e) {
 
}

key hash をコマンドラインで確認する方法もありますが、Windows用の OpenSSL を使わないといけないらしく、Mac用の OpenSSL だと正しい key hash が取得できないみたいです。

例えば、コマンドラインで keytool を使って debug.keystore の key hash を確認すると、 bvfSSDnrryuK8cbfekyHTs59l/A= です。

keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64
キーストアのパスワードを入力してください:  android
bvfSSDnrryuK8cbfekyHTs59l/A=

しかし、冒頭の方法で、アプリ実行時のログから key hash を出力させると dkgthMwGADFQ7/9fkMn4MUzpSWo= であり、こちらが正しい値です。

ややこしい話ですが、解決方法が分かって良かったです。

参考情報

[iOS] Facebook エラー:The Facebook server could not fulfill this access request: The app must ask for a basic read permission at install time.

Facebook iOS SDK version 3.5.1 で Facebook 認証を実装したらエラーが発生しました。

エラーログ

error:Error Domain=com.facebook.sdk Code=2
“The operation couldn’t be completed. (com.facebook.sdk error 2.)”
UserInfo=0x1e8b2740 {com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:SystemLoginCancelled, com.facebook.sdk:ErrorInnerErrorKey=Error Domain=com.apple.accounts
Code=7 “The Facebook server could not fulfill this access request: The app must ask for a basic read permission at install time.”
UserInfo=0x1ddf1eb0 {NSLocalizedDescription=
The Facebook server could not fulfill this access request: The app must ask for a basic read permission at install time.
}, com.facebook.sdk:ErrorSessionKey=, expirationDate: (null), refreshDate: (null), attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>}

最初、以下のように openActiveSessionWithPublishPermissions で、publish_actions だけ取得しようとしていたのですが「The app must ask for a basic read permission at install time.」というエラーメッセージの通り、まず basic profile information を取得する必要があるそうです。

+ (void)connectWithCompletionHandler:(void(^)(FBSession *session, FBSessionState status, NSError *error))handler {
    NSLog(@"Connection");
    if ([[FBSession activeSession] isOpen]) {
        NSLog(@"Logout");
        [[FBSession activeSession] closeAndClearTokenInformation];
    }
 
    // Request publish permissions
    NSArray *publishPermissions = [NSArray arrayWithObjects:@"publish_actions", nil];
    [FBSession openActiveSessionWithPublishPermissions:publishPermissions
                                       defaultAudience:FBSessionDefaultAudienceFriends
                                          allowLoginUI:YES
                                     completionHandler:handler];
}

なので、下記のように先に openActiveSessionWithReadPermissions を呼び出せばOKです。

+ (void)connectWithCompletionHandler:(void(^)(FBSession *session, FBSessionState status, NSError *error))handler {
    NSLog(@"Connection");
    if ([[FBSession activeSession] isOpen]) {
        NSLog(@"Logout");
        [[FBSession activeSession] closeAndClearTokenInformation];
    }
 
    // Request basic profile information
    // 基本情報で必要なものがある場合、指定する
    // NSArray *readPermissions = [NSArray arrayWithObjects:@"email", @"user_birthday", nil];
    NSArray *readPermissions = nil;
    [FBSession openActiveSessionWithReadPermissions:readPermissions
                                       allowLoginUI:NO
                                  completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
                                      /* handle success + failure in block */
                                  }];
 
    // Request publish permissions
    NSArray *publishPermissions = [NSArray arrayWithObjects:@"publish_actions", nil];
    [FBSession openActiveSessionWithPublishPermissions:publishPermissions
                                       defaultAudience:FBSessionDefaultAudienceFriends
                                          allowLoginUI:YES
                                     completionHandler:handler];
}

[参考]

Facebook iOS SDK3.5で投稿処理を行う際の流れ(その2) – assaulter's diary

[Facebook] Handling Revoked Permissions – 失効権限の取り扱い

Handling Revoked Permissions – Facebook Developers はてなブックマーク - Handling Revoked Permissions - Facebook Developers

Handling Revoked Permissions
失効権限の取り扱い

The Permissions that are requested from a User by an App may not be fully granted, or may not remain constant – a user can choose to not grant some Permissions and can revoke these Permissions afterwards through their Facebook account settings. In order to provide a positive user experience, Apps should be built to handle these situations.
アプリケーションによるユーザーから要求された権限は完全に付与されていないか、一定のままでないかもしれません – ユーザはいくつかの権限を付与しないように選択することができ、自分のFacebookのアカウント設定を介して、その後、これらの権限を取り消すことができます。肯定的なユーザーエクスペリエンスを提供するために、アプリはこれらの状況を処理するために構築されるべきである。

[Facebook] @proxymail.facebook.com のメールアドレスについて

Facebook アプリ経由でメールアドレスを渡すときに、登録しているメールアドレスではなく @proxymail.facebook.com のメールアドレスを渡すことができたみたいです。

・参考:Facebookのアプリやゲーム経由でスパマーにメールアドレスを漏らさないようにするには? | 適宜覚書-Fragments はてなブックマーク - Facebookのアプリやゲーム経由でスパマーにメールアドレスを漏らさないようにするには? | 適宜覚書-Fragments

以前のFacebookアプリの仕様では出来たみたいだけど、仕様変更があってからはできなくなったみたい?

(2012/07/07時点の情報です)

[Facebook] ページタブアプリ(iframe) でリダイレクト(redirect)できない問題と解決方法

Facebook のページタブアプリ(iframe) にて、リダイレクト(redirect)処理を実行すると、画面が真っ白になって何も表示されない問題でハマりました。

■ サーバーの request/response ログ

HTTP/1.1 302 Moved Temporarily
P3P: CP=”IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT”
Location: https://www.facebook.com/pages/My-Page/xxxxxxxxxxxx?sk=app_xxxxxxxxxx
Content-Type: text/html; charset=utf-8
X-UA-Compatible: IE=Edge
Cache-Control: no-cache
X-Request-Id: 8700a35ce62854a9d99abc225bbb9903
X-Runtime: 0.002538
Connection: close
Server: thin 1.3.1 codename Triple Espresso

<html><body>You are being <a href="https://www.facebook.com/pages/My-Page/xxxxxxxxxxxx?sk=app_xxxxxxxxxx">redirected</a>.</body></html>

原因は、ifranme 内からリダイレクトを行なっているせいでした。

a タグに、target=”_top” を指定して、フレーム解除してやればOKです。

■ エラーで動かない例

<a class="btn" href="https://graph.facebook.com/oauth/authorize?client_id=xxxxxxxxxxxxxxx&redirect_uri=https%3A%2F%2Flocalhost%3A3443%2Fcallback&scope=email">Facebook Auth</a>

■ 解決した例(target=”_top” を追加してる)

<a class="btn" href="https://graph.facebook.com/oauth/authorize?client_id=xxxxxxxxxxxxxxx&redirect_uri=https%3A%2F%2Flocalhost%3A3443%2Fcallback&scope=email" target="_top">Facebook Auth</a>

以上です。

FacebookアプリをFacebookページのタブに設置する方法

FacebookアプリをFacebookページのタブに設置する方法を調べたのでメモ。

https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&display=popup&next=YOUR_URL

・YOUR_APP_ID: タブとして追加したいアプリのAPP ID
・YOUR_URL: タブとして追加したいアプリが設置してあるルートURL(セキュアなURLの方がベター)

URLの太字になっている、「YOUR_APP_ID」、「YOUR_URL」の所を上記のように変更してリンク先を開きます。
すると以下のように「どのFacebookページに追加しますか?」というダイアログが表示されるかと思います。 

・引用元:Facebookアプリページが削除、タブの導入方法が変更へ | FBN Future box news | Facebook、Android、 iPhone WEBのこれからを伝えるメディア はてなブックマーク - Facebookアプリページが削除、タブの導入方法が変更へ | FBN Future box news | Facebook、Android、 iPhone WEBのこれからを伝えるメディア

Add PageTab at Facebook Page はてなブックマーク - Add PageTab at Facebook Page

FacebookページにIFrameタブを追加するツール: 小粋空間 はてなブックマーク - FacebookページにIFrameタブを追加するツール: 小粋空間

FacebookページへのIFrameタブ追加方法が変更: 小粋空間 はてなブックマーク - FacebookページへのIFrameタブ追加方法が変更: 小粋空間

もちろん、Facebook Developerの公式ドキュメントにも載ってます。

■ Direct URL Example

You can also bring up the Add to Page Dialog by explicitly directing the user to the /dialog/pagetab endpoint:

https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&display=popup&next=YOUR_URL

■ Properties

・app_id
Your application’s identifier. Required, but automatically specified by most SDKs.

・redirect_uri
The URL to redirect to after the user clicks the Add Page Tab or Cancel buttons on the dialog. Required, but automatically specified by most SDKs.

・display
The display mode in which to render the dialog. This is automatically specified by most SDKs.

・引用元:Add Page Tab Dialog – Facebook Developers はてなブックマーク - Add Page Tab Dialog - Facebook Developers

以上です。