Reputation: 111
I am currently developing a page which is able to upload the selected photos by administrator from the gallery to a Facebook Fan Page.
I am using CURL to upload the photo Facebook Fan Page. Yet I meet a significant error which I cannot find a solution using Google.
{"error":{"message":"(#114) An id must be a valid ID string (e.g., \"123\")","type":"OAuthException","code":114}}
This is the function I do post request. The request URL is as follow, which has a valid fan page id and its fan page access token (I can successfully get fan page data using GET by file_get_contents()) https://graph.facebook.com/289113764493682/photos/?access_token=XXXXXXXXXXXXXXXXXX
function do_post_request($url, $data, $files = null)
{
// echo '<pre>';echo $url;echo '</pre>';
$file = current($files);
// post information is rebuilt
$data = array_merge($data, array('source' => '@' . $files[0]));
// init and configure curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
// finally, send
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
I am using localhost to test my code. Temporarily I don't have a remote server. Shall I know where the problem is?
Upvotes: 0
Views: 1518
Reputation: 111
Finally I have found the problem why I am getting this problem This problem is solved. But I am sharing my problem so others can solve by themselves.
In my query string $data, I provided a 'place' attribute, That is array('access_token' => 'xxx', 'message' => 'xxx', 'place' => This is the reason I am getting this error.
Upvotes: 1