|
![Picture of Kim Aldis Picture of Kim Aldis](/graphics/unknown.gif) 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
![Picture of Manuel Lemos Picture of Manuel Lemos](/picture/user/1.jpg) 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);
![Picture of Kim Aldis Picture of Kim Aldis](/graphics/unknown.gif) 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
);
![Picture of Kim Aldis Picture of Kim Aldis](/graphics/unknown.gif) 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.
![Picture of Manuel Lemos Picture of Manuel Lemos](/picture/user/1.jpg) 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.
![Picture of Kim Aldis Picture of Kim Aldis](/graphics/unknown.gif) Kim Aldis - 2014-09-28 08:44:33 - In reply to message 5 from Manuel Lemos
I've tried that, same error.
![Picture of Manuel Lemos Picture of Manuel Lemos](/picture/user/1.jpg) 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.
![Picture of Kim Aldis Picture of Kim Aldis](/graphics/unknown.gif) 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.
![Picture of Manuel Lemos Picture of Manuel Lemos](/picture/user/1.jpg) Manuel Lemos - 2014-09-28 21:29:33 - In reply to message 8 from Kim Aldis
You're welcome. Good to know.
|