经过大量研究并在墙上撞了几下,我几乎结束了我的代码。 我能够连接到Facebook,甚至发送消息请求,但我无法发送图片。这是代码:
s3eFBRequest* pWallPostRequest = s3eFBRequest_WithGraphPath(MultiLoginScene::getSession(), "me/photos", "POST");
s3eFBRequest_AddParamString(pWallPostRequest, "picture", MakeScreenshot());
//s3eFBRequest* pWallPostRequest = s3eFBRequest_WithGraphPath(MultiLoginScene::getSession(), "me/feed", "POST");
//s3eFBRequest_AddParamString(pWallPostRequest, "message", "Here's a wall post!");
s3eFBRequest_AddParamString(pWallPostRequest, "access_token", s3eFBSession_AccessToken(MultiLoginScene::getSession()));
s3eFBRequest_Send(pWallPostRequest, GraphRequestCallback, NULL);
关于MakeScreenshot()
static void flipVertical(unsigned char *data, int w, int h)
{
int x, y, i1, i2;
unsigned char temp;
for (x=0;x<w;x++){
for (y=0;y<h/2;y++){
i1 = (y*w + x)*3; // this pixel
i2 = ((h - y - 1)*w + x)*3; // its opposite (across x-axis)
// swap pixels
temp = data[i1];
data[i1] = data[i2];
data[i2] = temp;
i1++; i2++;
temp = data[i1];
data[i1] = data[i2];
data[i2] = temp;
i1++; i2++;
temp = data[i1];
data[i1] = data[i2];
data[i2] = temp;
}
}
}
const char* MainMenuScene::MakeScreenshot()
{
static int count = 0;
static char file[] = "PicaSim-00000.png";
sprintf(file, "PicaSim-%05d.png", count++);
// int w = s3eSurfaceGetInt(S3E_SURFACE_WIDTH);
//int h = s3eSurfaceGetInt(S3E_SURFACE_HEIGHT);
int w = 600;
int h = 600;
int dataSize = w * h * 3;
unsigned char *framebuffer =
(unsigned char *) malloc(dataSize * sizeof(unsigned char));
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, framebuffer);
flipVertical(framebuffer, w, h);
/* CIwImage image;
image.SetFormat(CIwImage::BGR_888);
image.SetWidth(w);
image.SetHeight(h);
image.SetBuffers(framebuffer, dataSize);
image.SavePng(file);
free(framebuffer);*/
return (const char *)framebuffer;
}
毕竟我从回调中得到一个失败的回应......我能做错什么? 我只需要向Facebook发送一个截图... 知道为什么不起作用吗?
编辑:
所以我尝试发送一个URL作为参数,但仍然没有在这里工作的代码
s3eFBRequest* pWallPostRequest = s3eFBRequest_WithGraphPath(MultiLoginScene::getSession(), "me/photos", "POST");
s3eFBRequest_AddParamString(pWallPostRequest, "picture", "http://img1.wikia.nocookie.net/__cb20130407100142/onepiece/pt/images/d/d8/Goku_2.jpg");
s3eFBRequest_AddParamString(pWallPostRequest, "access_token", s3eFBSession_AccessToken(MultiLoginScene::getSession()));
s3eFBRequest_Send(pWallPostRequest, GraphRequestCallback, NULL);
但仍然没有工作......任何线索?
答案 0 :(得分:0)
您正在向Facebook发送一个帧缓冲区作为参数!!
Facebook仅接受图片网址作为picture
参数。因此,您的图片需要上传到网络服务器上,并且网址必须位于您发送帧缓冲区的picture
参数中。