0

アクションをタイムラインに公開するために、このスキームを使用しています。

    function postCook()
          {
              FB.api(
                '/me/app_url:action',
                'post',
                { object: 'url address' },
                function(response) {
                   if (!response || response.error) {
                      console.log(response);
                      alert('Error occured');
                   } else {
                      alert('Cook was successful! Action ID: ' + response.id);
                   }
                });
          }
<input type="button" value="Cook" onclick="postCook()" />

この JS 関数を PHP に書き直すにはどうすればよいですか? 私はこのようなことを試しました(ここで見つけたもの):

$myurl = 'https://graph.facebook.com/me/url_app_name:action?object=url_address&access_token=ACCESS_TOKEN&method=post';
$result = file_get_contents($myurl);

しかし、これは私にエラーを返します

Warning: file_get_contents(content of $myurl) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in...

Open Graph アクションを PHP で公開するにはどうすればよいですか?

4

1 に答える 1

0

Facebook PHP SDKを確認することをお勧めします。ドキュメントは (Facebook に関する限り) かなりよくできており、面倒な file_get_contents() の内容を抽象化します。

于 2012-09-15T13:58:10.840 に答える