【发布时间】:2017-11-02 20:27:08
【问题描述】:
我正在尝试使用访问令牌将以下代码发布到多个 Facebook 帐户上。我将访问令牌存储在文件 token.txt 中,并从该 token.txtfile 中获取访问令牌。
这是我的代码:
$a = file_get_contents("token.txt");
$token = explode("\n",$a);
$data['message'] = "Hello Friends xoxo :)";
$data['access_token'] = $token;
$post_url = 'https://graph.facebook.com/me/feed';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($ch);
curl_close($ch);
这是上面代码的输出:
PHP Notice: Array to string conversion in /home/masudtoo/public_html/mcteam/autopostfb.php on line 10
这是第 10 行的代码:
$fields_string .= $key . '=' . $value . '&';
代码有很多问题。如果您发现代码有任何问题,请尝试帮助我修复它。谢谢。
【问题讨论】:
-
你试过运行这段代码了吗?请将通过运行此代码生成的错误添加到问题中。谢谢。
-
PHP Notice: Array to string conversion in /home/masudtoo/public_html/mcteam/autopostfb.php on line 10和代码行 10:` $fields_string .= $key 。 '=' 。 $价值。 '&';` -
谢谢以后请把这个作为问题的一部分添加????
-
您收到该消息是因为您在做坏事。别再做坏事了。
-
您可能需要阅读平台政策
标签: php facebook facebook-graph-api curl