1

誰かがこの問題を解決するのを手伝ってくれますか? 私はこれについて過去 48 時間頭を悩ませています。

目的: 私は自分のウェブサイトを通じて友人の Facebook ウォールに情報を投稿しようとしています。以前はすべて正常に機能していましたが、現在エラーが発生しています。

Fatal error: Uncaught OAuthException: (#200) The user hasn't authorized the application to perform this action thrown in /home/abcd/public_html/front_apps/controllers/src/base_facebook.php on line 1039

また、私がやろうとしているのは、オフラインのときに友達の Facebook ウォールにcron投稿し、毎日午前 12 時までに投稿することです。

私はPHPコードを使用しています。コードは次のとおりです。

<?php

$message = "Message goes here";
$link = "http://link.com/";
$picture = "http://link.com/1.jpg";
$sendTo = "my friend id";
$access_token = "access tocken";

require 'src/facebook.php';
$facebook = new Facebook(array(
      'appId'  => 'appId',
      'secret' => 'secret_ID',
    )); <br>

$attachment = array('message' => $message, 'link' => $link, 'picture' => $picture );
$api = "/$sendTo/feed/?access_token='.$access_token,";
$result = $facebook->api($api,'post', $attachment);

?>
4

2 に答える 2

0

このリンクをチェックして、手順に従ってください。

http://eagerfish.eu/using-facebook-off-line-access-to-post-on-users-wall/ここにリンクの説明を入力

下のリンクもチェックして、

Uncaught OAuthException: (#200)、ウォールに投稿しようとすると、ここにリンクの説明を入力してください

于 2013-04-12T11:55:13.850 に答える
0

Facebook は Offline Access を廃止したため、長期間有効なトークン (60 日間有効) を取得してサーバーに保存する必要があります。これが私が使用しているものです。

長期間有効なトークンをすぐに取得するには、サーバー側のログイン フローを使用します

$code = $_REQUEST["code"];

//get acces token from user
$token_url = "https://graph.facebook.com/oauth/access_token?"."client_id=".$config[‘appId’]."&redirect_uri=".urlencode($my_url)."&client_secret=".$config[‘secret’]."&code=".$code;

$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);

$token = $params['access_token']; //long live the token

ユーザーウォールへの投稿

//construct the image URL
$url ="https://".$_SERVER['SERVER_NAME'].$event_data['path'];
$img_url = urlencode($url); //encode the URL
$text= urlencode($event_data['text']);

//post to user wall - picture and text 
$post_url= "https://graph.facebook.com/".$user_data['uid']."/photos?url=".$img_url."&message=".$text."&access_token=".$user_data['token']."&method=post";
$upload_photo = file_get_contents($post_url);

それが役に立てば幸い ;)

于 2013-04-11T22:29:23.170 に答える