0

我正在使用以下代码将照片上传到 Facebook

hconnect = WinHttpConnect(hsession,L"graph.facebook.com",INTERNET_DEFAULT_HTTPS_PORT,0);`hrequest = WinHttpOpenRequest( hconnect, L"POST", reqUrl,NULL, WINHTTP_NO_REFERER,WINHTTP_DEFAULT_ACCEPT_TYPES,WINHTTP_FLAG_SECURE);

            CString temp = L"Source:";
            temp += objDlg.fileName;

            bResult =  WinHttpAddRequestHeaders(hrequest,temp,(ULONG)-1L,WINHTTP_ADDREQ_FLAG_ADD );

            CString contentType(L"Content-Type:multipart/form-data");

            bResult =  WinHttpAddRequestHeaders(hrequest,contentType,(ULONG)-1L,WINHTTP_ADDREQ_FLAG_ADD );bResult = WinHttpSendRequest( hrequest,WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0,objDlg.fileLength, NULL);
                if(bResult)
                {
                    DWORD dwBytesWritten = 0;
                    bResult = WinHttpWriteData( hrequest,objDlg.memblock, objDlg.fileLength,&dwBytesWritten);}`

但它返回“期望上传文件作为响应。

谁能帮我吗。

提前致谢

4

1 回答 1

0

Faceebook 期望发布数据采用“多部分/表单数据”格式。相应地形成数据并将数据与 Winhttpsendrequest 一起发送。照片被上传并返回相应的ID。

于 2011-11-10T08:09:42.510 回答