将照片上传到 Facebook,返回“期望上传文件”

发布于 2024-12-12 01:46:01 字数 1027 浏览 0 评论 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);}`

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

任何人都可以帮助我。

提前致谢

I am using the following code to upload photo to 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);}`

but its returning "Expects Upload file as reponse.

Can anyone help me out.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月苍老的讽刺 2024-12-19 01:46:01

Faceebook 期望发布数据采用“multipart/form-data”格式。相应地形成数据并与 Winhttpsendrequest 一起发送数据。照片上传后会返回相应的ID。

Faceebook expects the post data in a "multipart/form-data" format. Form the data accordingly and send the data along with Winhttpsendrequest. The photo gets uploaded and the corresponding ID will be returned.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文