mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
Add typings for Facebook's ui method (#13611)
This commit is contained in:
parent
f31f6630d7
commit
a9bf9cf390
@ -39,3 +39,72 @@ FB.logout(function(response: fb.AuthResponse) {
|
||||
console.log(response.status);
|
||||
console.log(response.authResponse.accessToken);
|
||||
});
|
||||
|
||||
/**
|
||||
* Dialog samples from Facebook documentation:
|
||||
*/
|
||||
FB.ui({
|
||||
display: 'popup',
|
||||
method: 'live_broadcast',
|
||||
phase: 'create',
|
||||
}, response => {
|
||||
if (!response.id) {
|
||||
alert('dialog canceled');
|
||||
return;
|
||||
}
|
||||
alert('stream url:' + response.secure_stream_url);
|
||||
|
||||
FB.ui({
|
||||
display: 'popup',
|
||||
method: 'live_broadcast',
|
||||
phase: 'publish',
|
||||
broadcast_data: response,
|
||||
}, response => {
|
||||
alert("video status: \n" + response.status);
|
||||
});
|
||||
});
|
||||
|
||||
FB.ui({
|
||||
method: 'pay',
|
||||
action: 'purchaseitem',
|
||||
product: 'YOUR_PRODUCT_URL'
|
||||
}, data => {
|
||||
console.log(data.payment_id);
|
||||
});
|
||||
|
||||
FB.ui({
|
||||
method: 'pagetab',
|
||||
redirect_uri: 'YOUR_URL'
|
||||
}, response => {});
|
||||
|
||||
FB.ui({
|
||||
method: 'send',
|
||||
link: 'http://www.nytimes.com/interactive/2015/04/15/travel/europe-favorite-streets.html',
|
||||
}, response => {});
|
||||
|
||||
FB.ui({
|
||||
method: 'apprequests',
|
||||
message: 'Take this bomb to blast your way to victory!',
|
||||
to: 'USER_ID, USER_ID, INVITE_TOKEN',
|
||||
action_type:'send',
|
||||
object_id: 'YOUR_OBJECT_ID', // e.g. '191181717736427'
|
||||
}, response => {
|
||||
console.log(response);
|
||||
});
|
||||
|
||||
FB.ui({
|
||||
method: 'apprequests',
|
||||
message: 'Friend Smash Request!',
|
||||
filters: [
|
||||
{ name:'GROUP_1_NAME', user_ids:['USER_ID','USER_ID','USER_ID'] },
|
||||
{ name:'GROUP_2_NAME', user_ids: ['USER_ID','USER_ID','USER_ID'] },
|
||||
]
|
||||
}, response => {
|
||||
console.log(response);
|
||||
});
|
||||
|
||||
FB.ui({
|
||||
method: 'share',
|
||||
mobile_iframe: true,
|
||||
href: 'https://developers.facebook.com/docs/',
|
||||
}, response => {});
|
||||
|
||||
124
facebook-js-sdk/index.d.ts
vendored
124
facebook-js-sdk/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
// Type definitions for the Facebook Javascript SDK
|
||||
// Type definitions for the Facebook Javascript SDK 2.8
|
||||
// Project: https://developers.facebook.com/docs/javascript
|
||||
// Definitions by: Amrit Kahlon <https://github.com/amritk/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@ -12,7 +12,7 @@ declare namespace facebook {
|
||||
AppEvents: any;
|
||||
Canvas: any;
|
||||
Event: any;
|
||||
|
||||
|
||||
/**
|
||||
* The method FB.getAuthResponse() is a synchronous accessor for the current authResponse.
|
||||
* The synchronous nature of this method is what sets it apart from the other login methods.
|
||||
@ -50,8 +50,33 @@ declare namespace facebook {
|
||||
* @param callback function to handle the response
|
||||
*/
|
||||
logout(callback: (response: AuthResponse) => void): void;
|
||||
|
||||
ui: any;
|
||||
|
||||
/**
|
||||
* @see https://developers.facebook.com/docs/sharing/reference/share-dialog
|
||||
*/
|
||||
ui(params: ShareDialogParams, callback: (response: ShareDialogResponse) => void): void;
|
||||
|
||||
/**
|
||||
* @see https://developers.facebook.com/docs/games/services/gamerequests
|
||||
*/
|
||||
ui(params: GameRequestDialogParams, callback: (response: GameRequestDialogResponse) => void): void;
|
||||
|
||||
/**
|
||||
* @see https://developers.facebook.com/docs/payments/reference/paydialog
|
||||
*/
|
||||
ui(params: PayDialogParams, callback: (response: PayDialogResponse) => void): void;
|
||||
|
||||
/**
|
||||
* @see https://developers.facebook.com/docs/videos/live-video/exploring-live
|
||||
*/
|
||||
ui(params: LiveDialogParams, callback: (response: LiveDialogResponse) => void): void;
|
||||
|
||||
/**
|
||||
* @see https://developers.facebook.com/docs/sharing/reference/send-dialog
|
||||
* @see https://developers.facebook.com/docs/pages/page-tab-dialog
|
||||
*/
|
||||
ui(params: SendDialogParams | AddPageTabDialogParams, callback: (response: null) => void): void;
|
||||
|
||||
XFBML: any;
|
||||
}
|
||||
|
||||
@ -73,6 +98,68 @@ declare namespace facebook {
|
||||
profile_selector_ids?: string;
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
//
|
||||
// DIALOGS
|
||||
//
|
||||
////////////////////////
|
||||
|
||||
interface DialogParams {
|
||||
app_id?: string;
|
||||
redirect_uri?: string;
|
||||
display?: 'page' | 'iframe' | 'async' | 'popup';
|
||||
}
|
||||
|
||||
interface ShareDialogParams extends DialogParams {
|
||||
method: 'share';
|
||||
href: string;
|
||||
hashtag?: string;
|
||||
quote?: string;
|
||||
mobile_iframe?: boolean;
|
||||
}
|
||||
|
||||
interface AddPageTabDialogParams extends DialogParams {
|
||||
method: 'pagetab';
|
||||
redirect_uri: string;
|
||||
}
|
||||
|
||||
interface GameRequestDialogParams extends DialogParams {
|
||||
method: 'apprequests';
|
||||
message: string;
|
||||
action_type?: 'send' | 'askfor' | 'turn';
|
||||
data?: number;
|
||||
exclude_ids?: string[];
|
||||
filters?: 'app_users' | 'app_non_users' | Array<{ name: string, user_ids: string[] }>;
|
||||
max_recipients?: number;
|
||||
object_id?: string;
|
||||
suggestions?: string[];
|
||||
title?: number;
|
||||
to?: string | number;
|
||||
}
|
||||
|
||||
interface SendDialogParams extends DialogParams {
|
||||
method: 'send';
|
||||
to?: string;
|
||||
link: string;
|
||||
}
|
||||
|
||||
interface PayDialogParams extends DialogParams {
|
||||
method: 'pay';
|
||||
action: 'purchaseitem';
|
||||
product: string;
|
||||
quantity?: number;
|
||||
quantity_min?: number;
|
||||
quantity_max?: number;
|
||||
request_id?: string;
|
||||
test_currency?: string;
|
||||
}
|
||||
|
||||
interface LiveDialogParams extends DialogParams {
|
||||
method: 'live_broadcast';
|
||||
display: 'popup' | 'iframe';
|
||||
phase: 'create' | 'publish';
|
||||
broadcast_data?: LiveDialogResponse;
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
//
|
||||
@ -87,6 +174,33 @@ declare namespace facebook {
|
||||
expiresIn: number;
|
||||
signedRequest: string;
|
||||
userID: string;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
interface ShareDialogResponse {
|
||||
post_id?: string;
|
||||
error_message?: string;
|
||||
}
|
||||
|
||||
interface GameRequestDialogResponse {
|
||||
request: string;
|
||||
to: string[];
|
||||
}
|
||||
|
||||
interface PayDialogResponse {
|
||||
payment_id: string;
|
||||
amount: string;
|
||||
currency: string;
|
||||
quantity: string;
|
||||
request_id: string;
|
||||
status: string;
|
||||
signed_request: string;
|
||||
}
|
||||
|
||||
interface LiveDialogResponse {
|
||||
id: string;
|
||||
stream_url: string;
|
||||
secure_stream_url: string;
|
||||
status: string;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user