Hello all!
I've been beating my head against an issue with Facebook integration using the 3.x version of the SDK and was having no luck with Google, so I thought perhaps one of you wonderful people had figured this one out and would be willing to pass along some advice and knowledge.
Using the sdk, I can create, edit, and delete calendar posts without any issues. Wall posts, however, I can create and delete.
$FB = new Facebook($my_config_array);
//to create a wall post - this works
$post_id = $FB->api('USER_ACCESS_TOKEN/feed', 'POST', array('message'=>'hello world'));
//to delete a wall post - this also works
$FB->api($post_id, 'DELETE', array('access_token'=>$this->getPageAccessToken()));
//I've tried many variation on the following, but nothing thus far has worked...
$FB->api($post_id, 'POST', array('access_token'=>$this->getPageAccessToken(),'message'=>'hello world edited'));
private function getPageAcessToken(){
$accounts = json_decode(file_get_contents("https://graph.facebook.com/me/accounts?access_token=".USER_ACCESS_TOKEN));
if(is_array($accounts->data)){
for($i=0; $i<count($accounts->data); $i++){
if($accounts->data[$i]->id == $this->_user_creds['user_id']){
return $accounts->data[$i]->access_token;
}
}
}
return $accounts->data->access_token;
}
For the graph call, I've tried targeting the post id, the user id plus '/feed', just '/feed' stream and I've gotten Facebook to duplicate the post, as long as the message is different. It will not, however, update an existing post. My current work-around is to delete the existing post and create a new one with the new text. The problem there is I lose all comments and likes on every update if I do that, which will be an issue with my users.
Anybody have any thoughts on the subject?
Thanks in advance for any and all ideas and/or advice!