我正在使用Open Graph,其中操作类型为“Repin”,对象类型为“视频”。当我尝试发布时,我遇到了一些错误。我怎样才能消除这个错误?
请看下面的代码。但是,我一次又一次地查看 Open Graph 动作和对象。在错误控制台中,我得到了响应HTTP//1.1 200 OK 1857
。
<?php
require 'data/facebook/src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxx',
));
// See if there is a user from a cookie
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
}
catch (FacebookApiException $e) {
echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';
$user = null;
}
}
?>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
xmlns:fb="https://www.facebook.com/2008/fbml">
<title>OG Tutorial App</title>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# xxxxxxxxxx: http://ogp.me/ns/fb/xxxxxxxxxxx#">
<meta property="fb:app_id" content="xxxxxxxxxxxxx" />
<meta property="og:type" content="<namespace>:<action>" />
<meta property="og:url" content="<#### My URL ######>" />
<meta property="og:title" content="Sample Video" />
<meta property="og:image" content="http://xxxxxxxxxxxxxxxxxxxximage.jpeg" />
<script type="text/javascript">
########### MAIN FOCUS ON THESE BELOW LINES ###############################
function postCook()
{
FB.api(
'/me/<namespace>:<action>',
'post',
{<graph object>: 'http://xxxxxxURLxxxxxxxxxxx' },
function(response) {
//alert(response.responseText);
console.log(response);
if (!response || response.error) {
alert('An error occurred.');
}
else {
alert('Cook was successful! Action ID: ' + response.id);
}
});
}
###################################################################################
</script>
</head>
<body>
<div id="fb-root"></div>
<div id="fb-root"></div>
<script>
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
FB.Event.subscribe('auth.logout', function(response) {
window.location.reload();
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
<h3>Stuffed Cookies</h3>
<p>
<img title="Stuffed Cookies"
src="http://xxxxxxxxxxxxxxxxxxxxxx.jpeg"
width="200"/>
</p>
<br>
<form>
<input type="button" value="Cook" onclick="postCook()" />
</form>
</body>
</html>