如何获得";图形API对象ID”;用于cURL到Linter工具


How to get "Graph API Object ID" for cURL to Linter tool?

我正在尝试使用以下接受URL的脚本ping Facebook linter。

它一直给我错误:

{
  "error":{
    "message": "(#803) Some of the aliases you requested do not exist: http'u00253A'u00252F'u00252Fgoogle.com",
    "type":"OAuthException",
    "code":803
  }
}

不过,如果我转到实际的linter工具,并放入http://google.com,它将在底部生成一个URL,如下所示:

https://graph.facebook.com/381702034999

如果我把那个ID放回我的代码中,代替URL,它会突然起作用。

我该怎么做?它应该以URL作为输入:

<?
  $url = urlencode($_GET['url']);
  $access_token = "APP_ID|APP_SECRET";
  $params = array(
    'id' => $url,
    'scrape' => 'true',
    'access_token' => $access_token
  );
  $ch = curl_init("https://graph.facebook.com");
  curl_setopt_array($ch, array(
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_SSL_VERIFYHOST => false,
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_POST           => true,
    CURLOPT_POSTFIELDS     => $params
  ));
  $result = curl_exec($ch);
  echo $result;

我认为发生这种情况是因为您可能使用了错误的编码。。。如果我尝试

https://graph.facebook.com/?id=http%3A%2F%2Fgoogle.com&scrape=true&access_token={access_token}

我得到以下结果:

{
   "id": "http://google.com",
   "shares": 8654603,
   "comments": 133590
}