[英]Sharing post using Facebook Graph API in Android
我正在嘗試在應用程序內部使用Facebook API共享帖子,我在Facebook Developer上創建了一個帳戶,並將應用程序ID放在應用程序內部,登錄過程正常,如果我共享了來自開發人員Facebook帳戶的帖子,每個事情很好。 但是當我嘗試使用任何其他Facebook帳戶共享時,我什么也沒有共享。 我使用的是Facebook SDK 3.5,以下為共享代碼:
/**
* Post message with image
*
* @param imageURl
*/
public void postStatusMessage( byte [] imageURl ) {
if ( checkPermissions( Session.getActiveSession() ) ) {
final CustomProgressDialog progress = new CustomProgressDialog( FBActivity.this ) ;
progress.show() ;
// Filling the needed data for the share
Bundle parameters = new Bundle() ;
parameters.putString( "message" , shareText.getText().toString() ) ; // message
parameters.putString( "description" , name ) ;// description
parameters.putString( "link" , linkUrl ) ;// link if available
parameters.putByteArray( "picture" , imageURl ) ;// byte array for the image so it can be shared as image not as link
Request.Callback callback = new Request.Callback() {
public void onCompleted( Response response ) {
if ( response.getError() == null ) {
// Share post was done succesfully
Toast.makeText( FBActivity.this , getString( R.string.statusUpdateSucc ) , Toast.LENGTH_LONG ).show() ;
onlineActionID = ( String ) response.getGraphObject().getProperty( "id" ) ;
shareSuccesfuly = true ;
} else {
// Fail in share
Toast.makeText( FBActivity.this , "" + getString( R.string.statusUpdateFail ) , Toast.LENGTH_LONG ).show() ;
}
// Dismiss progress dialog
if ( progress.isShowing() )
progress.dismiss() ;
// if share was done sucessfully , navigate back to the previvos page
if ( shareSuccesfuly ) {
finish() ;
}// end if.
else {
finish() ;
}// end else().
}
} ;
// Request should have the me/photos tag so we can share photos in the user profile
Request request = new Request( Session.getActiveSession() , "me/photos" , parameters , HttpMethod.POST , callback ) ;
request.executeAsync() ;
} else {
requestPermissions() ;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.