drzb7969753 2016-08-21 01:36
浏览 22

如何使用图形api编码/解码facebook评论回复?

Here is the code i have:

    $message = urlencode($message);
    $params[] = "message=".$message;
    $params = implode('&',$params);

    $curl = curl_init($this->graph_api.$object_id.'/comments?access_token='.$access_token);
    curl_setopt($curl,CURLOPT_POST,true);
    curl_setopt($curl,CURLOPT_POSTFIELDS,$params);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,0);
    curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0);

    $response = curl_exec($curl);
    curl_close($curl);

Currently there is problem with decoding i guess, when there is symbol in the comment reply for example:

comment: >>> contact

will output: & gt;& gt;& gt; contact (without space between & gt;)

same goes to other symbol. i think no problem with encode, only for decode. i'm not sure how this api graph works for decoding. really appreciated for any help.

and one more thing, for private_replies, is it possible to include url? because sometimes there is block/filter by facebook to avoid spamming i guess. any advice for this?

  • 写回答

1条回答 默认 最新

  • dongyanling9248 2016-08-21 21:24
    关注

    issue solved based on this answer : https://stackoverflow.com/a/7796870/3613026

    just decode from database (eg: & gt;& gt;& gt;) and send as decode message (will be: >>>) to graph api. no magic. :)

    $message = html_entity_decode($message, ENT_COMPAT, "UTF-8");
    $params[] = "message=".$message;
    $params = implode('&',$params);
    
    $curl = curl_init($this->graph_api.$object_id.'/comments?access_token='.$access_token);
    curl_setopt($curl,CURLOPT_POST,true);
    curl_setopt($curl,CURLOPT_POSTFIELDS,$params);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,0);
    curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0);
    
    $response = curl_exec($curl);
    curl_close($curl);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据