错误:编译错误:方法不存在或签名不正确:ConnectApi.BinaryInput

时间:2013-08-21 21:46:51

标签: salesforce apex-code salesforce-chatter

我在顶点编写代码来设置用户的聊天照片。我写了一个函数

public PageReference setPhoto() {
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    string firstImageURL = 'https://ap1.salesforce.com/resource/1377118388000/sample_pic';
    firstImageURL = firstImageURL.replace(' ', '%20');
    req.setEndpoint(firstImageURL);
    req.setMethod('GET');
    req.setHeader('Content-Type', 'image/jpeg');
    req.setCompressed(true);
    req.setTimeout(60000);
    HttpResponse res = null;
    res = h.send(req);
    blob image = res.getBodyAsBlob();
    ConnectApi.BinaryInput bb = ConnectApi.BinaryInput(image, 'image/png', 'myfile');
    System.debug('user is' + ConnectApi.ChatterUsers.setPhoto(null, '00590000001jFln', bb));
    return null;
}

当我尝试保存它时,它给了我错误

Error: Compile Error: Method does not exist or incorrect signature: ConnectApi.BinaryInput(Blob, String, String) at line 28 column 27

我跟着这个http://www.salesforce.com/us/developer/docs/apexcode/Content/connectAPI_inputs.htm#capi_binary_input 你能指导一下这个文件是错还是正确?以及如何获取ConnectApi.BinaryInput实例

1 个答案:

答案 0 :(得分:0)

您尝试将实例方法用作静态方法。创建ConnectApi.BinaryInput

的实例
ConnectApi.BinaryInput binaryInput = new ConnectApi.BinaryInput(fileBlob, null, filename);