2
我用我最近開發FB應用張貼在牆上和它顯示了以下錯誤如何解決OAuthException:(#100)
未捕獲OAuthException:(#100)圖片網址的格式不正確扔
你也可以看到這直接*https://apps.facebook.com/hack-proof_pages/1gp.html
使用兩個文件 「1gp.html」 和 「gp1.php」
1gp.html碼
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="gp1.php">
<p>message
<textarea style="width:300px; height:50px;" name="message1"></textarea>
</p>
<p>link
<input type="text" style="width:300px;" name="link1" />
</p>
<p>
Picture
<input type="text" name="picture1" />
</p>
<p>
name
<input type="text" style="width:300px;" name="name1" />
</p>
<p>
Caption
<input type="text" style="width:300px;" name="caption1" />
</p>
<p>Description
<textarea style="width:300px; height:50px;" name="description1"></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Submit" />
</p>
</form>
</body>
</html>
gp1.php代碼
<?php
require_once 'library/facebook.php';
// Create our Application instance.
$facebook = new Facebook(array(
'appId' => '149865361795547',
'secret' => 'shhhh seceret :)',
'cookie' => true,
));
$app_id = '149865361795547';
$canvas_page = "https://apps.facebook.com/hack-proof_pages/gp1.php";
//get data for post
$message1 = $_POST['message1'];
$picture1 = $_POST['picture1'];
$name1 = $_POST['name1'];
$link1 = $_POST['link1'];
$caption1 = $_POST['caption1'];
$description1 = $_POST['description1'];
// compile the post for for user
$WallPost = array(
'message' => $message1,
'link' => $link1,
'picture' => $picture1,
'name' => $name1,
'caption' => $caption1); // you can also use 'picture', 'link', 'name', 'caption', 'description', 'source'....
//http://developers.facebook.com/docs/reference/api/
$auth_url = "http://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page) . ("&scope=email,read_stream,publish_stream,offline_access,publish_actions,manage_pages,user_groups&response_type=token");
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
if (empty($data["user_id"])) {
echo("<script> top.location.href='" . $auth_url . "'</script>");
} else {
//getting the userid and some other data for verification
//get the user id
$UserId = $data["user_id"];
echo 'UserId;' . $UserId;
//get the user access token
$atoken = $facebook->getAccessToken();
echo "</br>" . 'User Access_Token:' . $atoken;
//set default access token and profile
//$facebook->setAccessToken($atoken);
//$user_profile = $facebook->api('/me');
//get the user name and email
$user_id = $facebook->getUser();
$user_profile = $facebook->api('/me','GET');
$user_name = $user_profile['name'];
echo "Name: " . $user_name;
$user_email = $user_profile['email'];
echo "email: " . $user_email;
// post to user wall
$response = $facebook->api('/me' . '/feed','POST',$WallPost);
//posting to groups wall with sleeping time support poster.xls
}
?>
* 注:我的應用程序使用自簽名證書的SSL,因此如果你想測試這一點,你需要讓我的網站,上面存儲的URL證書和一個更多的信息,有時谷歌鉻顯示錯誤,由於谷歌瀏覽器鉻的一個薄弱點,鉻需要在Internet Explorer中存儲自簽名證書意味着如果你想檢查這在鉻你需要先在Internet Explorer中打開此網站,並允許我的網站自簽名證書和永久存儲,以便它也窩鉻鉻合金
我沒有在你的編碼中發現任何錯誤我也不明白爲什麼得到錯誤 – 2012-03-25 17:37:53
你得到的錯誤說你有一個圖片的URL的問題,你究竟傳遞了什麼*圖片*參數?我看到你從用戶帖子的形式得到它,但輸入類型是文本,用戶將在那裏放置什麼?當你有這個錯誤時,你在那裏有什麼? – 2012-03-25 19:01:05
你也可以嘗試自己我的圖片網址很簡單,就像http://example.com/mypic.jpg – 2012-03-26 10:35:56