Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.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-Facebook在墙上的帖子,包含双引号的消息_Php_Facebook Graph Api - Fatal编程技术网

php-Facebook在墙上的帖子,包含双引号的消息

php-Facebook在墙上的帖子,包含双引号的消息,php,facebook-graph-api,Php,Facebook Graph Api,我正试着在Facebook的墙上发帖,代码如下。消息有时包含双引号或在墙上转换的其他字符,不知道如何解决此问题。下面是我正在使用的代码 更新 $title = get_the_title($post->ID); // using wordpress posts' title //$title = "John's message has \"\" double quotes"; I thought it might be facebook doing something with the

我正试着在Facebook的墙上发帖,代码如下。消息有时包含双引号或在墙上转换的其他字符,不知道如何解决此问题。下面是我正在使用的代码

更新

$title = get_the_title($post->ID); // using wordpress posts' title

//$title = "John's message has \"\" double quotes"; I thought it might be facebook doing something with the title. but by using raw according to Tim, it worked.

                    $attachment = array(
                        'access_token' => $smm_fb_access_token,
                        'message' => $title,
                        'name' => "Site.com",
                        'link' => $handler_url,
                    );

                    $facebook->api(sprintf('/%s/feed', $fb_id), 'POST', $attachment);
Facebook上的帖子就是这样的

John’s message has ““ double quotes.

请指导我应该怎么做才能使它工作?

您的代码中没有任何HTML会转义您的
$title
字符串,因此它会转义到其他地方

您给出的HTML编码也是“奇特的引号”,而不是示例
$title
字符串中的ASCII字符。(即
而不是
)因此,如果有其他东西在逃避它,它是在故意引用。(就像wordpress可能会巧妙地做的那样)

我建议发布更多的代码,显示数据在Facebook SDK中的变化

更新

$title = get_the_title($post->ID); // using wordpress posts' title

//$title = "John's message has \"\" double quotes"; I thought it might be facebook doing something with the title. but by using raw according to Tim, it worked.

                    $attachment = array(
                        'access_token' => $smm_fb_access_token,
                        'message' => $title,
                        'name' => "Site.com",
                        'link' => $handler_url,
                    );

                    $facebook->api(sprintf('/%s/feed', $fb_id), 'POST', $attachment);
由于这是wordpress,因此必须在不进行HTML转义的情况下检索
$title
字符串。避免
获取转义的\u title
,而是使用

$title = $post->post_title;
// rest of your code.

请注意,Wordpress筛选器不会应用于此字符串,希望这是您想要的。如果这不是您想要的,您必须像使用
一样获取标题,然后HTML解码字符串。这对您的情况没有帮助,因为PHP无法解码unicode实体。I strongl不管怎样,我还是推荐前一种方法。

谢谢@Tim,基本上我所做的就是将我的博客文章从wordpress发布到facebook的墙上。所以我得到的标题是
$title=get_title($post->ID)
有时会有双引号等,然后它就变成了我在问题中解释的那样。我想是的。你应该指定Wordpress,并且你正在这样做。更新答案…感谢原始作品,我以为facebook在做些什么。我尝试了
html\u实体\u解码
,但它不起作用是的,PHP无法解码
 “;
因为它是unicode。我最好也把它添加到我的答案中。