1
$response = $facebook->api(
  'me/objects/namespace:result',
  'POST',
  array(
    'app_id' => app_id,
    'type' => "namespace:result",
    'url' => "http://samples.ogp.me/370740823026684",
    'title' => "Sample Result",
    'image' => "https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png",
    'description' => ""
  )
);

次のエラーが表示されます。

The parameter object is required

パラメータ オブジェクトを追加する場所がわかりません。

4

1 に答える 1

0

過去数日間、同じ問題に直面していました。最終的に、Facebook PHP SDK を使用してリクエストを送信しようとするのをやめ、HTTP リクエストを送信するだけに頼りました。

オブジェクトを更新するのではなく、オブジェクトを作成していますが、実装はあなたのニーズとあまり変わらないはずです。同じエラーが発生し (パラメーター オブジェクトが必要です)、以下の実装でその問題が解決されました。

vinelab HTTP クライアント コンポーザ パッケージを使用して、次のようなリクエストを作成しました。

$request = [
        'url' => 'https://graph.facebook.com/me/objects/namespace:object',
        'params' => [
            'access_token' => $fbAccessToken,
            'method' => 'POST',
            'object' => json_encode([
                'fb:app_id'         => 1234567890,
                'og:url'            => 'http://samples.ogp.me/1234567890',
                'og:title'          => 'Sample Object',
                'og:image'          => 'https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png',
                'og:description'    => 'Sample Object'
            ])
        ]
    ];

// I'm using Laravel so this bit might look different for you (check the vine lab docs if you use that specific HTTP client)
$response = HttpClient::post($request);

// raw content
$response->content();

// json
$response->json();

前述したように、実装では vinelab HTTP パッケージを使用しましたが、同様のパッケージを使用するか、代わりに PHP で直接 curl を使用できるはずです。

于 2014-11-18T10:31:36.057 に答える