PHP Classes

Facebook image posting error

Recommend this page to a friend!

      PHP OAuth Library  >  All threads  >  Facebook image posting error  >  (Un) Subscribe thread alerts  
Subject:Facebook image posting error
Summary:Facebook image upload returns 'requires upload file', code=324
Messages:9
Author:Kim Aldis
Date:2014-09-27 16:25:55
 

  1. Facebook image posting error   Reply   Report abuse  
Picture of Kim Aldis Kim Aldis - 2014-09-27 16:25:55

I'm posting images to Facebook using the following:

CallAPI( "https://graph.facebook.com/me/photos", 'POST',
array( 'message' => "some message", 'source' => '@' . $filepath ),
array( 'FailOnAccessError' => true ),
$user)

It's failing with an error from Facebook:-

it was not possible to access the API call: it was returned an unexpected response status 400 Response: {"error":{"message":"(#324) Requires upload file","type":"OAuthException","code":324}}


I'm reasonably sure that if I was using the Facebook API I'd fix this by calling $facebook->setFileUploadSupport(true); Can this be done with the OAuth API? Is it even the right solution?

thanks

Kim







  2. Re: Facebook image posting error   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-09-27 22:22:50 - In reply to message 1 from Kim Aldis
You need to pass an additional option telling which parameters are files:

$success = $client->CallAPI(
"https://graph.facebook.com/me/photos",
'POST', array(
'message'=>'Some message',
'source'=>$filepath
),
array(
'FailOnAccessError'=>true,
'Files'=>array(
'source'=>array(
)
)
), $upload);

  3. Re: Facebook image posting error   Reply   Report abuse  
Picture of Kim Aldis Kim Aldis - 2014-09-28 06:37:33 - In reply to message 2 from Manuel Lemos
No, sorry, same error using this code:



$success=$this->client->CallAPI(
'https://graph.facebook.com/me/photos,
'POST', array(
'message'=> $message,
'source' => '@' . $filepath
),
array(
'FailOnAccessError'=>true,
'Files'=>array(
'source'=>array()
)
),
$user
);

  4. Re: Facebook image posting error   Reply   Report abuse  
Picture of Kim Aldis Kim Aldis - 2014-09-28 06:46:59 - In reply to message 3 from Kim Aldis
Addendum:

I've checked the filepath carefully, it is correct.

If I use the url parameter, 'url' => $urlToImage, it posts. I can work with this for now but it would be useful to know what's going on with the source parameter, for future reference.


K.

  5. Re: Facebook image posting error   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-09-28 06:59:25 - In reply to message 3 from Kim Aldis
No, that is wrong, stop adding the @ character to the file name. That is a convention used by Curl functions. This class does not use Curl functions.

  6. Re: Facebook image posting error   Reply   Report abuse  
Picture of Kim Aldis Kim Aldis - 2014-09-28 08:44:33 - In reply to message 5 from Manuel Lemos
I've tried that, same error.

  7. Re: Facebook image posting error   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-09-28 09:34:58 - In reply to message 6 from Kim Aldis
Yes, it was working only for OAuth 1 servers. I just uploaded a new version that also supports OAuth 2 servers. Just let me know if you still have difficulties.

  8. Re: Facebook image posting error   Reply   Report abuse  
Picture of Kim Aldis Kim Aldis - 2014-09-28 11:23:25 - In reply to message 7 from Manuel Lemos
That did it. Many thanks.

This is turning out to be a nice general purpose API of OAuth. I've tried a few and this is proving to be the most consistent and reliable across a range of sites. Your efforts are much appreciated.

  9. Re: Facebook image posting error   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-09-28 21:29:33 - In reply to message 8 from Kim Aldis
You're welcome. Good to know.