问题
I created a search bar that uses the graph API and it worked fine until about a month ago. You could type something into the search bar, and get info back from Facebook related to your search parameter. It stopped working for some reason. So I went to my browsers search bar to type in a graph search manually like this-
http://graph.facebook.com/search?q=zombies
This doesn't work anymore either and I get an error message that says this-
{ "error": { "message": "(#200) Must have a valid access_token to access this endpoint", "type": "OAuthException", "code": 200 } }
Was there an update that made my search stop working? I've been reading Facebook's documentation and I can't find what I'm looking for. Can someone help me get this working again? My search is located at http://ericnaff.com/html5/p3. Here's my script that I am using-
function searchFB(userSearchparameter) {
$.getJSON('https://graph.facebook.com/search?q=' + userSearchparameter + '&type=post&callback=?', function(fbResults){
$.each(fbResults.data, function() {
// Data Templating
$('<article class="fbResults"></article>').append (
'<section class="resultsSource"><h6 class="shareHeader">' +
'<img class="fromUser" src="https://graph.facebook.com/' + this.from.id + '/picture" height="50" width="50" alt="' + this.from.name + '">' +
'<a href="http://www.facebook.com/' + this.from.id + '" class="fromName">' + this.from.name +'</a> shared a <a class="typeLink" href="' + this.link + '">' + this.
type + '</a> </h6>' +
'<time class="createdTime" datetime="' + this.created_time + '">' + fuzzyFacebookTime(this.created_time.replace(/-/g,'/')) + ' ·</time>' +
'<img class="typeLinkIcon" src="' + this.icon + '" alt="icon"></section>' +
'<section class="resultsDescription"><h6><a class="shareLink" href="' + this.link + '">' +
'<img class="sharePicture" src="' + this.picture + '" height="90" width="90" alt="' + this.from.id + '">' +
'<span class="shareName">' + this.name + '</span>' +
'<span class="shareCaption">' + this.caption + '</span>' +
'<span class="shareDescription">' + this.message + '</span>' +
'</a></h6></section>' +
'<iframe class="linkShare" src="http://facebook.com/plugins/like.php?href=' + this.link + '"></iframe>'
).appendTo('body');
I know it says I don't have the correct access token in my error, but it never used one in the first place and worked fine. If I need to add one, where would I want to include that? Thanks!
回答1:
You will need an access token; this means an [registered Facebook App][1]
Facebook API changes Jul 10 '13:
Graph API search changes
App access tokens will be required for all search Graph API calls except Places and Pages. Search for application will no longer be supported.
- Create an Facebook developer account
- Create a new Facebook App
- GET https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=client_credentials
- Append the returned access_token=... to your search requests
回答2:
Access tokens will also be required for Post searches too:
From Facebook's Developer Roadmap of Completed Changes:
Graph API search changes
User access tokens will be required for all search Graph API calls except Posts, Places and Pages. App access tokens may also be used for Post search Graph API calls. Places and Pages search Graph API calls will still require an App access token. Search for Applications will no longer be supported.
来源:https://stackoverflow.com/questions/17977385/facebook-graph-api-search-issue