0

在 twitter 搜索 API 中,您可以使用每个搜索结果必须回复该帖子的唯一 ID。

例如(php):

$twitter_json = file_get_contents("http://search.twitter.com/search.json?q=".$query."&lang=en", true);
$twitter_search_res = json_decode($twitter_json, true);
$id = $twitter_search_res['results'][0]['id'];
echo "<a href = 'https://twitter.com/intent/tweet?in_reply_to={$id}'>";

如何回复 Facebook 图表搜索返回的帖子?

$fb_json = file_get_contents("http://graph.facebook.com/search?q=".$query."", true);
$fb_search_res = json_decode($fb_json, true);

结果之一是:

array(7) {
  ["id"]=>
  string(31) "100000101152749_627923180554381"
  ["from"]=>
  array(2) {
    ["name"]=>
    string(19) "Jellie Artus Judith"
    ["id"]=>
    string(15) "100000101152749"
  }
  ["message"]=>
  string(101) "here comes the most awaited event of our lives. hahaha graduation of Wave95 (expedia)
:) pakaL time.."
  ["privacy"]=>
  array(1) {
    ["value"]=>
    string(0) ""
  }
  ["type"]=>
  string(6) "status"
  ["created_time"]=>
  string(24) "2013-04-18T19:18:23+0000"
  ["updated_time"]=>
  string(24) "2013-04-18T19:18:23+0000"
}

我厌倦了使用https://graph.facebook.com/{$fb_result_id}/comments,但图形搜索返回的 id 似乎不是正确的。我还在“_”处拆分了 id,但这些都不起作用。

4

1 回答 1

0

https://developers.facebook.com/docs/reference/api/search/所示,http ://graph.facebook.com/search?q=YOUR_QUERY是搜索所有公开帖子,这种帖子很可能不是您朋友的帖子,通常您没有评论权限。

如果你想从你的新闻提要中搜索帖子,你可以这样做

https://graph.facebook.com/me/home?q=a&access_token=USER_ACCESS_TOKEN

post_id 使用 curl 的示例评论:

 <?php
    //extract data from the post
    extract($_POST);

    //set POST variables
    $url = 'https://graph.facebook.com/150552388343703_483757795023159/comments?access_token=USER_ACCESS_TOKEN';
    $msg = 'hello world testing';
    $fields = array(
                            'message' => urlencode($msg),
                    );

    //url-ify the data for the POST
    foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
    rtrim($fields_string, '&');

    //open connection
    $ch = curl_init();

    //set the url, number of POST vars, POST data
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_POST, count($fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

    //execute post
    $result = curl_exec($ch);

    //close connection
    curl_close($ch);

    ?>
于 2013-04-19T07:18:31.840 回答