Ich habe CodeIigniter 3 Projekt, wo ich eine Blog-Posts Funktionalität habe und ich möchte eine Auto-Post auf Facebook-Seite hinzufügen. Ich habe das HyBridAuth bereits mit meinem CodeIgniter 3 Projekt konfiguriert. Außerdem habe ich mein Facebook bereits authentifiziert und die Daten der Facebook-Sitzung mit einem Zugangstoken gespeichert.Veröffentlichen Sie einen Beitrag auf einer Facebook-Seite als Seite Admin
Jetzt versuche ich auf meiner Facebook-Seite zu posten. Ich habe die folgende Methode erstellt.
public function facebook_post() {
if ($this->ion_auth->logged_in()) {
$this->data['userInformation'] = $this->ion_auth->user()->row();
}
$this->data['userid'] = $this->data['userInformation']->id;
$this->data["facebook_status"] = $this->admin_model->getStoredHybridSession($this->data['userid'], "Facebook");
if(!empty($this->data['facebook_status'][0])) {
if($this->data["facebook_status"] != "0") {
$this->data["facebook_profile"] = $this->get_profile("Facebook");
$access_token = explode('&', $this->data['facebook_profile']->coverInfoURL);
$a_t = explode('=', $access_token[1]);
$params = array(
"access_token" => $a_t[1],
"message" => "Here is a blog post about auto posting on Facebook using PHP",
"link" => "http://facebook.com",
"picture" => "https://i.telegraph.co.uk/multimedia/archive/03474/Facebook_3474124b.jpg",
"name" => "Auto post functionality test",
"caption" => "https://facebook.com",
"description" => "Automatically post on Facebook with PHP using Facebook PHP SDK. How to create a Facebook app. Obtain and extend Facebook access tokens. Cron automation."
);
$facebook = $this->hybridauthlib->authenticate("Facebook");
$ret = $facebook->api()->api('/1388840631445245/feed', 'POST', $params);
owndebugger('Successfully posted to Facebook');
}
} else {
$this->data["facebook_profile"] = 0;
}
}
Dieser Code funktioniert. Aber, Mein Post auf der Seite als Besucher Beiträge posten.
Was mache ich falsch?
Ohne Ihren Code auszuchecken, verwenden Sie höchstwahrscheinlich ein Benutzer-Token anstelle eines Page-Tokens. – luschn
@luschn - Seiten-Token? :(Es scheint mir sehr neue Begriffe. Wie bekomme ich das? –
http://www.devils-heaven.com/facebook-access-tokens/ – luschn