-1

私のインデックス ファイルでは、image.php ファイルからランダム化された画像を表示します。インデックスファイルに画像を表示してFacebookの壁に投稿する方法を見つけようとしています。

image.php から生成された画像を Facebook の壁に投稿する方法はありますか?

//index file
<img src="image.php">

//post to wall file
$facebook->api("/me/feed", "post", array(
    'message' => "",
    'picture' => "",       //same image from image.php goes here
    'link' => "",
    'name' => "",
    'caption' => ""
));
4

2 に答える 2

0

サイトがexample.comの場合、これは問題なく機能するはずです。

'message' => 'http://example.com/image.php',

注:引用符と一貫性を保つことをお勧めします。常に一重引用符または二重引用符を使用します。ここで行ったように混合しないでください。

アップデート

画像を表示する画像タグを次のように置き換えます。

//index file
<img src="image.php?postfb=1">

image.php

// image selection/generation code first
// there's probably an URL to the image here somewhere, I'll assume its $image_url

// then:
if (isset ($_GET ['postfb'])) {
    //post to wall file
    $facebook->api("/me/feed", "post", array(
        'message' => "",
        'picture' => $image_url, 
        'link' => "",
        'name' => "",
        'caption' => ""
    ));
}
于 2012-05-12T18:13:02.847 に答える
0

このコードを試してください

以下のように $img_path 変数に画像パスを保存します

$img_path = file_get_contents('imgage.php');

image.php が画像の実際のパスを表示する場合、例: http://www.example.com/image/sample.jpg。それを実際のパスとして作成しない場合....そうでなければ、fbは画像を受け入れません...

FB ウォールに投稿するコード

 $attachment = array('message' => 'message'
           'name' => 'Sample',
           'picture' => $img_path);

 $result = $facebook->api('/'. $fb_id . '/feed/', 
                          'post',
                           $attachment);
于 2012-05-12T18:50:16.397 に答える