2

如何编辑此代码以在我的墙上发布例如目录中的照片:“C:\myfiles\myphoto.jpg”?

FacebookType publishPhotoResponse = facebookClient.publish("me/photos", FacebookType.class,
  BinaryAttachment.with("cat.png", getClass().getResourceAsStream("/cat.png")),
  Parameter.with("message", "Test cat"));
4

1 回答 1

2

你只需cat.png要用你的绝对图像路径替换代码。像这样的东西:

    InputStream is = new FileInputStream(new File("C:\\myfiles\\myphoto.jpg"));
    FacebookType publishVideoResponse =facebookClient.publish("me/photos",FacebookType.class,
            BinaryAttachment.with("myphoto.jpg", is),
            Parameter.with("message", "MY PHOTO POST"));        
于 2013-10-31T04:52:37.577 回答