簡體   English   中英

在C#中使用Facebook API

[英]Using Facebook API in C#

你好!

所以我正在使用Xamarin在C#中使用android應用程序,這是一個學校項目。 但是,由於facebook api的文檔全部在java中,因此有時很難找出確切的用途或找到其他遇到相同問題的人。 現在是我的問題; 我正在嘗試設置一個sharecontent按鈕,以打開一個sharecontent對話框,到目前為止一切正常。 我正在嘗試將照片添加到共享中,這就是當狗屎撞到風扇時,我擁有的照片是可繪制的。 嘗試執行此操作時,我總是收到錯誤消息。

我的密碼

    /* Facebook Share Code */
mBtnShared = view.FindViewById<ShareButton>(Resource.Id.btnShare); //Facebook share
mCallBackManager = CallbackManagerFactory.Create();
int id = 0;
Bitmap icon = BitmapFactory.DecodeResource(Resource.Drawable.A1010_1, id);
SharePhoto sharePhoto1 = new SharePhoto.Builder()
.SetBitmap(icon)
.Build();
ShareContent content = new ShareMediaContent.Builder().AddMedium(sharePhoto1).Build();
ShareDialog shareDialog = new ShareDialog(this.Activity);
shareDialog.Show(content);

api范例; https://developers.facebook.com/docs/sharing/android/#Multimedia

    SharePhoto sharePhoto1 = new SharePhoto.Builder()
    .setBitmap(...)
    .build();
SharePhoto sharePhoto2 = new SharePhoto.Builder()
    .setBitmap(...)
    .build();
ShareVideo shareVideo1 = new ShareVideo.Builder()
    .setLocalUrl(...)
    .build();
ShareVideo shareVideo2 = new ShareVideo.Builder()
    .setLocalUrl(...)
    .build();

ShareContent shareContent = new ShareMediaContent.Builder()
    .addMedium(sharePhoto1)
    .addMedium(sharePhoto2)
    .addMedium(shareVideo1)
    .addMedium(shareVideo2)
    .build();

ShareDialog shareDialog = new ShareDialog(...);
shareDialog.show(shareContent, Mode.AUTOMATIC);

我收到的錯誤在屏幕上: 錯誤 所以我想我的位圖有些問題,但是我絕對在這里迷路了。 我希望你們能幫助我!

問候,耶隆!

好像我錯過了導致錯誤的演員表,需要在新的SharePhoto(..)前面添加(SharePhoto); 固定的:D

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM