打开Graph cURL命令行 --> php?

发布于 2024-12-28 02:01:48 字数 304 浏览 0 评论 0原文

我快要疯了。我需要以下 cURL 命令行作为 PHP 脚本,当用户访问某个页面时自动触发“读取”操作:

curl -F 'access_token=XXXXXXXXX' \
     -F 'article=<?php the_permalink(); ?>' \
        'https://graph.facebook.com/me/lemberg_dk:read'

我花了过去 24 小时研究 cURL 并试图了解如何将其转换为 PHP,但我根本就是无法掌握它。

这里有人可以帮助我吗?

I am going nuts about this. I need the following cURL command line as a PHP script, that automatically triggers a "read" action when a user visits a certain page:

curl -F 'access_token=XXXXXXXXX' \
     -F 'article=<?php the_permalink(); ?>' \
        'https://graph.facebook.com/me/lemberg_dk:read'

I have spent the last 24 hours researching cURL and trying to understand how to convert it to PHP, but I simply just can't grasp it.

Can anybody here help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮萍、无处依 2025-01-04 02:01:48

试试这个:

$ch = curl_init('https://graph.facebook.com/me/lemberg_dk:read');
curl_setopt_array($ch, array(
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => array(
        'access_token' => 'XXXXXXXXX',
        'article' => the_permalink()
    )
));
$response = curl_exec($ch);
curl_close($ch);

执行后,您将在 $response 变量中获得服务器响应。

当然,要使其正常工作,您需要加载 cURL 扩展。

Try this:

$ch = curl_init('https://graph.facebook.com/me/lemberg_dk:read');
curl_setopt_array($ch, array(
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => array(
        'access_token' => 'XXXXXXXXX',
        'article' => the_permalink()
    )
));
$response = curl_exec($ch);
curl_close($ch);

After execution you will get server response in $response variable.

Of course to make it to work you will need cURL extension loaded.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文