gpt4 book ai didi

java - 在 Facebook 上发布图片不起作用

转载 作者:行者123 更新时间:2023-12-02 00:13:21 25 4
gpt4 key购买 nike

我正在尝试在 Facebook 上上传图片。使用此代码

      private void getFb()
{

final SharedPreferences mPrefs = getSharedPreferences(
"fbPref", Activity.MODE_PRIVATE);

String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);
if(access_token != null) {
fb.setAccessToken(access_token);
}
if(expires != 0) {
fb.setAccessExpires(expires);
}

if(!fb.isSessionValid())
{
fb.authorize(this, new String[] {"publish_stream"}, new DialogListener() {
public void onComplete(Bundle values) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token", fb.getAccessToken());
editor.putLong("access_expires", fb.getAccessExpires());
editor.commit();
}

public void onFacebookError(FacebookError error) {}

public void onError(DialogError e) {}

public void onCancel() {}
});
}

}



@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
fb.authorizeCallback(requestCode, resultCode, data);

Bundle parameters = new Bundle();
// parameters.putString(Facebook.TOKEN, fb.getAccessToken());
// The byte array is the data of a picture.
parameters.putString("message", "LolCats Test");
parameters.putString("picture", "http://cdn3.f-cdn.com/ppic/514992/logo/597178/profile_logo_597178.jpg");
parameters.putString("caption", "LLoll casts");

try {
fb.request("me/photos", parameters, "POST");

} catch (FileNotFoundException fileNotFoundException) {
// makeToast(fileNotFoundException.getMessage());
} catch (MalformedURLException malformedURLException) {
// makeToast(malformedURLException.getMessage());
} catch (IOException ioException) {
// makeToast(ioException.getMessage());
}

}

唯一发生的事情是打开 FB 应用程序页面,执行一些进度条,然后返回应用程序,没有错误等。图像未在 Facebook 上共享有什么问题?

最佳答案

请尝试这个。

parameters.putString("message", "LolCats Test");
parameters.putByteArray("source", "http://cdn3.fcdn.com/ppic/514992/logo/597178/profile_logo_597178.jpg".getBytes());

关于java - 在 Facebook 上发布图片不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12345973/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com