似乎没有明确的参考.我正在创建一个Android应用程序,用户可以登录到FB.
我在FB网站上关注了本教程,该网站提供了一个从网址发布图片的示例:postParams.putString("picture","https:// image URL");
但是,我想从我的项目上传到登录用户的时间轴上的本地PNG图像,该图像位于所有可重新绘制的文件夹中.
这是我的代码:
void publishStory()
{
Session session = Session.getActiveSession();
if (session != null)
{
Bundle postParams = new Bundle();
postParams.putString("name", "Name here.");
postParams.putString("caption", "Caption here.");
postParams.putString("description", "Description here.");
postParams.putString("link", "https://developers.facebook.com/android");
byte[] data = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Bitmap bi = BitmapFactory.decodeResource(getResources(),R.drawable.logonew);
bi.compress(Bitmap.CompressFormat.PNG, 100, baos);
data = baos.toByteArray();
postParams.putString("method", "photos.upload");
postParams.putByteArray("picture", data);
Request.Callback callback = new Request.Callback()
{
public void onCompleted(Response response)
{
FacebookRequestError error = response.getError();
if (error …Run Code Online (Sandbox Code Playgroud)