我正在尝试使用php从我的网站自动在我的Facebook页面上发布消息。 我面临的问题是,当我使用WAMPSERVER从localhost运行php脚本时,脚本运行正常。 但是当我在网络服务器上传它时会引发以下异常
/无法连接到主机
请帮帮我。
/<?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';
}
?>