我是黑莓新手。我想從我的應用程序發佈Facebook信息。我讀了一些文件。什麼是與Facebook集成的步驟?任何人都有一個工作的例子Java代碼呢?如何獲得api_key,secret_key,application_id?Facebook與黑莓整合
謝謝
我是黑莓新手。我想從我的應用程序發佈Facebook信息。我讀了一些文件。什麼是與Facebook集成的步驟?任何人都有一個工作的例子Java代碼呢?如何獲得api_key,secret_key,application_id?Facebook與黑莓整合
謝謝
請訪問下面的鏈接。在這裏您可以下載Blackberry的Facebook SDK。您也可以下載清楚地展示您的本地bb應用程序的facebook集成的示例。
@krishna看看下面的代碼。這基本上用於在牆上發佈消息。
/**
* Copyright (c) E.Y. Baskoro, Research In Motion Limited.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* This License shall be included in all copies or substantial
* portions of the Software.
*
* The name(s) of the above copyright holders shall not be used
* in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization.
*
*/
package samples.strawberry;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.ObjectChoiceField;
import net.rim.device.api.ui.component.SeparatorField;
import net.sf.blackberry.facebook.FBUser;
import net.sf.blackberry.facebook.FacebookContext;
import net.sf.blackberry.facebook.User;
import net.sf.blackberry.facebook.ui.FacebookScreen;
final class PostWallScreen extends FacebookScreen {
// List of actions:
static final String ACTION_ENTER = "postWall";
static final String ACTION_SUCCESS = "posted";
static final String ACTION_ERROR = "error";
// List of labels:
private static final String LABEL_TITLE = "Post To Wall";
private static final String LABEL_USERS = "Post wall to";
private static final String LABEL_NAME = "Title:";
private static final String LABEL_LINK = "Link:";
private static final String LABEL_CAPTION = "Caption:";
private static final String LABEL_CONTENT = "Content:";
private static final String LABEL_POST = "Post";
private User[] users = null;
private ObjectChoiceField objectChoiceField;
private EditField titleEditField;
private EditField hrefEditField;
private EditField captionEditField;
private EditField descriptionEditField;
private ButtonField buttonField;
/**
* Default constructor.
*
*/
PostWallScreen(FacebookContext pfbc) {
super(pfbc);
setTitle(new LabelField(LABEL_TITLE, LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH));
objectChoiceField = new ObjectChoiceField();
objectChoiceField.setLabel(LABEL_USERS);
add(objectChoiceField);
add(new SeparatorField(SeparatorField.LINE_HORIZONTAL));
titleEditField = new EditField(LABEL_NAME, "", 80, LabelField.USE_ALL_WIDTH);
add(titleEditField);
hrefEditField = new EditField(LABEL_LINK, "", 80, LabelField.USE_ALL_WIDTH);
add(hrefEditField);
captionEditField = new EditField(LABEL_CAPTION, "", 80, LabelField.USE_ALL_WIDTH);
add(captionEditField);
descriptionEditField = new EditField(LABEL_CONTENT, "", 255, LabelField.USE_ALL_WIDTH);
add(descriptionEditField);
buttonField = new ButtonField(LABEL_POST);
buttonField.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
if (users == null) {
return;
}
try {
users[objectChoiceField.getSelectedIndex()].publishStream(descriptionEditField.getText(), hrefEditField.getText(), titleEditField.getText(), descriptionEditField.getText(), captionEditField.getText());
fireAction(ACTION_SUCCESS);
} catch (Exception e) {
fireAction(ACTION_ERROR, e.getMessage());
}
}
});
add(buttonField);
}
/**
* Load list of users comprising of friends and self.
*
*/
void loadList() {
try {
User[] friends = new FBUser("me", fbc.getAccessToken()).getFriends();
if (friends == null) {
users = new User[1];
} else {
users = new User[friends.length + 1];
}
users[0] = new FBUser("me", fbc.getAccessToken());
for (int i = 1; i < (friends.length + 1); i++) {
users[i] = friends[i - 1];
}
objectChoiceField.setChoices(users);
} catch (Exception e) {
fireAction(ACTION_ERROR, e.getMessage());
}
}
}
是的,我發現這個代碼。在這段代碼中,從我的應用程序中傳遞字符串的位置?請幫幫我。非常感謝您的支持。 – krishna
謝謝Neel。我已經檢查過這個演示。我可以幫助我。在第一個屏幕上,一個鏈接即將命名爲BLACKBERRY SDK DEMO。我點擊了它。它成功連接到Facebook。但是如何將信息從我的應用程序發佈到牆上? – krishna
檢查下面的答案 –
@Nilanchala:我剛剛下載該演示,並嘗試運行與黑莓應用程序(不作爲庫),它給了我像「NoClassDefenationFound」異常。請幫助我去那 –