dr897777 2014-02-14 12:48
浏览 35

FB-> api抛出异常

I am trying to post messages on my facebook page automatically from my website using php. The problem i am facing is that when i run the php script from localhost using WAMPSERVER the script works fine. But when i upload it on webserver it throws the following exception

/couldn't connect to host

Please help me.

    /<?php
    // Path to PHP-SDK

    require_once("php-sdk/facebook.php"); // set the right path

    $config = array();
    $config['appId'] = 'xxxxxxxxxx';
    $config['secret'] = 'xxxxxxxxx';
    $config['fileUpload'] = false; // optional
    $fb = new Facebook($config);

    $params = array(
    // this is the main access token (facebook profile)
    "access_token" => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "message" => "Here is a blog post about auto posting on Facebook without being 
     signed in using PHP #php #facebook",
    "link" => "http://www.pontikis.net/blog/auto_post_on_facebook_with_php",
    "picture" => "http://i.imgur.com/lHkOsiH.png",
    "name" => "How to Auto Post on Facebook with PHP",
    "caption" => "www.pontikis.net",
    "description" => "Automatically post on Facebook with PHP using Facebook PHP SDK.  
      How to create a Facebook app. Obtain and extend Facebook access tokens. Cron 
      automation."
     );

    try {
         $ret = $fb->api('/me/feed', 'POST', $params);
         echo 'Successfully posted to Facebook Personal Profile';
    } catch(Exception $e) {
         echo $e->getMessage();
         echo 'not published';
    }

   ?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用