Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php FQL查询通过风扇页面ID获取风扇页面名称返回null_Php_Json_Facebook_Facebook Graph Api_Facebook Fql - Fatal编程技术网

Php FQL查询通过风扇页面ID获取风扇页面名称返回null

Php FQL查询通过风扇页面ID获取风扇页面名称返回null,php,json,facebook,facebook-graph-api,facebook-fql,Php,Json,Facebook,Facebook Graph Api,Facebook Fql,突然之间,FQL查询不起作用了,我已经用了这么多个月的代码并一直在运行,现在它不起作用了,甚至我以前的项目也没有用过 比如说,, 我有一个名为示例页面1的风扇页面名,其id为540109632726307 因此,我要做的是,使用风扇页面id检索风扇页面的名称 查询 代码 当我运行代码时,结果是NULL,与以前不同。facebook是否更新了fql查询?我似乎也找不到关于它的任何消息 但是当我运行到浏览器的链接时 https://graph.facebook.com/fql?q=SELECT+na

突然之间,FQL查询不起作用了,我已经用了这么多个月的代码并一直在运行,现在它不起作用了,甚至我以前的项目也没有用过

比如说,, 我有一个名为示例页面1的风扇页面名,其id为540109632726307

因此,我要做的是,使用风扇页面id检索风扇页面的名称

查询

代码

当我运行代码时,结果是NULL,与以前不同。facebook是否更新了fql查询?我似乎也找不到关于它的任何消息

但是当我运行到浏览器的链接时

https://graph.facebook.com/fql?q=SELECT+name+FROM+page+WHERE+page_id=540109632726307
它显示我进行的fql查询的结果

{
   "data": [
      {
         "name": "Sample Page One"
      }
   ]
}
这是一个有效的url。我的代码有问题吗?

三件事-

  • fb_id
    定义为:

    $fbp_id = "540109632726307"
    
    (因为它是一个大整数)

  • 在以下位置中的
    =
    后不留空格:

    page_id= '.$fbp_id
    
  • 没有变量
    $json\u output
    ,请在
    var\u dump
    中使用
    $fql\u query\u obj

  • 因此,您的代码将如下所示:

    $fbp_id = "540109632726307"; //Sample FB ID
    $fql_query_url = 'https://graph.facebook.com/'.'fql?q=SELECT+name+FROM+page+WHERE+page_id='.$fbp_id.'';
    $fql_query_result = file_get_contents($fql_query_url);
    $fql_query_obj = json_decode($fql_query_result, true);
    
    var_dump($fql_query_obj);
    

    试试看。

    为什么要在$fql\u query\u url中串联两个字符串?它可能只是一根线。 您也不需要在末尾连接单引号

    您是否尝试通过api.facebook.com url获取该文件

    e、 g

    Facebook是非常不合理的。有时graph.facebook.com可以使用,有时您需要使用api.facebook.com

    page_id= '.$fbp_id
    
    $fbp_id = "540109632726307"; //Sample FB ID
    $fql_query_url = 'https://graph.facebook.com/'.'fql?q=SELECT+name+FROM+page+WHERE+page_id='.$fbp_id.'';
    $fql_query_result = file_get_contents($fql_query_url);
    $fql_query_obj = json_decode($fql_query_result, true);
    
    var_dump($fql_query_obj);
    
    $fbp_id = "540109632726307"; //Sample FB ID
    $fql_query_url = 'https://api.facebook.com/method/fql.query?query=SELECT+name+FROM+page+WHERE+page_id='.$fbp_id;
    $fql_query_result = file_get_contents($fql_query_url);
    $fql_query_obj = json_decode($fql_query_result, true);
    var_dump($fql_query_obj);