Php 如何解决异常:(100)
我使用我最近开发的fb应用程序在我的墙上发布,它显示了以下错误 未捕获的OAutheException:100图片URL的格式不正确 您也可以直接看到这一点 使用两个文件1gp.html和gp1.php 1gp.html代码 gp1.php代码Php 如何解决异常:(100),php,facebook,facebook-graph-api,Php,Facebook,Facebook Graph Api,我使用我最近开发的fb应用程序在我的墙上发布,它显示了以下错误 未捕获的OAutheException:100图片URL的格式不正确 您也可以直接看到这一点 使用两个文件1gp.html和gp1.php 1gp.html代码 gp1.php代码 <?php require_once 'library/facebook.php'; // Create our Application instance. $facebook = new Facebook(array( 'appId'
<?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,您需要允许我的网站并存储其证书和一个更多信息,有时谷歌chrome会显示由于谷歌chrome导致的错误chrome需要在internet explorer中存储自签名证书的一个弱点意味着如果您想签入此项chrome您需要首先在internet explorer中打开此网站,并允许我的网站自签名证书和永久存储,这样它也可以在chrome中工作请检查您的图片url,您需要提供照片的完整url而不是相对url,facebook应该能够访问图片url,也就是说,它不应该是您本地托管的应用程序的url,请尝试在您的代码中放置任何图片的完全限定的示例url并进行检查。请检查您的图片url,您需要提供图片的完整url而不是相对url,facebook应该能够访问图片url,也就是说,它不应该是您本地托管的应用程序的url,尝试将任何图片的完全限定的示例url放入您的代码中并进行检查。我在您的编码中没有发现任何错误,我也不明白为什么会出现错误。您收到的错误表示您对图片的url有问题,您在图片参数中传递了什么?我看到你是从用户发布的表单中得到的,但是输入类型是文本,用户会在其中输入什么?当你遇到那个错误时,你在那里有什么?你也可以自己尝试我的pic url很简单,就像被否决一样,因为你的测试url不起作用,你没有说你的pic的url实际上是什么。@吉尔伯曼谢谢你的评论:我希望你能投赞成票,因为我还更新了这个信息,我的应用程序使用了自签名证书SSL,以便如果你想测试这一点,你需要允许我的网站和存储其证书和一个更多的信息,有时谷歌铬显示错误,由于谷歌铬一个弱点,铬需要存储自签名证书在internet explorer中意味着如果你想检查这一点在铬你需要首先打开这个网站在internet explorer和允许它的自签名证书和永久存储,因此它也可以在chromei中工作。我没有发现您的编码中有任何错误。我也不明白为什么会出现错误。您收到的错误表示您对图片的url有问题,您在图片参数中传递了什么?我看到你是从用户发布的表单中得到的,但是输入类型是文本,用户会在其中输入什么?当你遇到那个错误时,你在那里有什么?你也可以自己尝试我的pic url很简单,就像被否决一样,因为你的测试url不起作用,你没有说你的pic的url实际上是什么。@吉尔伯曼谢谢你的评论:我希望你能投赞成票,因为我还更新了这个信息,我的应用程序使用了自签名证书SSL,以便如果你想测试这一点,你需要允许我的网站和存储其证书和一个更多的信息,有时谷歌铬显示错误,由于谷歌铬一个弱点,铬需要存储自签名证书在internet explorer中意味着如果你想检查这一点在铬你需要首先打开这个网站在internet explorer和允许它的自签名证书并永久存储,因此它也可以在chrome中工作
<?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
}
?>