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 + '">' +
'' + this.from.name +' 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!
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
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.
Related
I am trying to load/save a document from S3 using AWS API (S3 proxy) and angular js. code as below
response type is marked as array buffer and is then converted as blob with UTF8 and type as "application/msword" (verified content type from S3 API)
download is successful however the file isn't showing up and an error "select encoding that makes your document readable"
tried with pdf document with type application/pdf, pdf opens but shows no data.
Any clue whats wrong here
$scope.URL = "https://jkq1yea3e5.execute-api.ap-south-1.amazonaws.com/Prod" + "/s3resources/"+"testfolder/"+ $scope.filename;
$http.get($scope.URL, {responseType: "arraybuffer"}).
success(function(data) {
$scope.info = "Read '" + $scope.URL + "' with " + data.byteLength
+ " bytes in a variable of type '" + typeof(data) + "'";
blob= new Blob([data], {type: $scope.type+";charset=utf-8"});
var url = window.URL.createObjectURL(blob);
var linkElement = document.createElement('a');
linkElement.setAttribute('href', url);
linkElement.setAttribute("download", $scope.filename);
linkElement.click();
FileSaver.saveAs(blob, $scope.filename,true);
After struggling for hours, here is what worked for me.
added application/msword in binary types for the AWS API
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings-workflow.html
When I query my web service to find a user, if that user is not part of a SharePoint group for the site, the ID is -1.
However, the user CAN get to the site, via a group permission. So my web service call cannot add the user to a "people" box within a list, even though SharePoint itself CAN add it.
My Web service call is as follows:
String searchText = "[My User's Login Name, Spelled Exactly as it appears in SharePoint.]";
String maxresults = "100";
String pType = "All";
String body = "<?xml version=\"1.0\"?>"
+ "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
+ " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<soap:Body>"
+ " <SearchPrincipals "
+ " xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">"
+ " <searchText>" + searchText + "</searchText>"
+ " <maxResults>" + maxResults + "</maxResults>"
+ " <principalType>" + pType + "</principalType>"
+ " </SearchPrincipals>"
+ " </soap:Body>"
+ "</soap:Envelope>";
I get the following response from the web service call:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<SearchPrincipalsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<SearchPrincipalsResult>
<PrincipalInfo>
<AccountName>[User's Account Name]</AccountName>
<UserInfoID>-1</UserInfoID> <------------ NOTE THE -1 HERE -----------------
<DisplayName>[User's full name, exactly as I sent it in]</DisplayName>
<Email>...</Email>
<Department>...</Department>
<Title>...</Title>
<IsResolved>true</IsResolved>
<PrincipalType>User</PrincipalType>
</PrincipalInfo>
</SearchPrincipalsResult>
</SearchPrincipalsResponse>
</soap:Body>
</soap:Envelope>
If I use this information to add a user to a "people" box, via the web service, The entry becomes "-1;#My User Name", which of course it cannot find, so the List.asmx webservice returns an error of 0x81020054 : The user does not exist or is not unique.
When I add the user to a group within the site directly, their ID resolves out just fine and everything goes through as normal. I remove them from the group and it returns to -1 again.
Any thoughts and/or suggestions for always returning a valid ID?
I can see you are using SearchPrincipals method. Instead try using ResolvePrincipals method.
Documentation here: http://msdn.microsoft.com/en-us/library/people.people.resolveprincipals(v=office.12).aspx
That method has a bool parameter where you can specify that if the user does not belong to the site, then it should be added, this way you will always make sure that you are always getting the ID even if the user does not belong to the site.
PeopleWebService.People pe = new PeopleWebService.People(); //People.asmx web service
string[] users = new string[] { "youruser" };
PeopleWebService.PrincipalInfo[] pInfo = pe.ResolvePrincipals(users, PeopleWebService.SPPrincipalType.User, true); //third param is true
string userID = pInfo[0].UserInfoID.ToString();
I'm implementing the X-FACEBOOK-PLATFORM XMPP authentication in Objective C (but using mostly C++ code) and I am getting always a failure:
<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>
I have the the app registered and the Id and Secret are as follows:
FacebookId #"136973476410894"
FacebookSecret #"f6e269fe158b4a04d00ce8b311453ccd"
I retrieve the session Token with FBConnect asking for the privileges:
#"publish_stream" ,#"xmpp_login" , #"offline_access"
The Session token is called token in the code (see below)
And then the program asks for the authentication mechanism:
<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="X-FACEBOOK-PLATFORM"/>
Receiving the challenge: <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dmVyc2lvbj0xJm1ldGhvZD1hdXRoLnhtcHBfbG9naW4mbm9uY2U9OTAzMTM5MjY2ODk3N0Q0ODMyNDQ2MDY1REMzMTE5RTc=</challenge>
Then the Facebook Auth body extracted from the challenge: version=1&method=auth.xmpp_login&nonce=9031392668977D4832446065DC3119E7.
key: version, value: 1.
key: method, value: auth.xmpp_login.
key: nonce, value: 9031392668977D4832446065DC3119E7.
token: "BAAB8k59ntg4BANNuTHAkjTZBk3pW8pZBD7jWIpZBt8cf65oAT4eDm9euloGCX9NzfF9HwKQxUdEQ15YfeFtkdZAHVpkjL0j4CF0lZCQeuNTBXrvkbtUXC"
APIkey: "136973476410894"
APISecret: "f6e269fe158b4a04d00ce8b311453ccd"
Using the code from below a response is built:
token = Session token from FB connect: (BAAB8k59ntg4BANNuTHAkjTZBk3pW8pZBD7jWIpZBt8cf65oAT4eDm9euloGCX9NzfF9HwKQxUdEQ15YfeFtkdZAHVpkjL0j4CF0lZCQeuNTBXrvkbtUXC)
APIkey = FacebookId (136973476410894);
APISecret = FacebookSecret (f6e269fe158b4a04d00ce8b311453ccd);
string call_id=[[NSString stringWithFormat:#"%0.0f", [[NSDate date] timeIntervalSince1970]] UTF8String];
string signature1 = "api_key=" + APIkey
+ "call_id=" + call_id
+ "method=auth.xmpp_login"
+ "nonce=" + nonce
+ "session_key=" + token
+ "v=1.0"
+ APISecret;
string md = MD5(signature1);
//std::transform(md.begin(), md.end(),md.begin(), ::tolower);
string response2 = "method=auth.xmpp_login&api_key=" + APIkey + "&session_key=" +token + "&call_id=" + call_id + "&sig=" + md + "&v=1.0&" + "nonce=" + nonce;
printf("++base64EncodedResponse response2: %s.\n", response2.c_str());
string response2Base64 = Base64::Encode(response2);
Built response: method=auth.xmpp_login&api_key=136973476410894&session_key=BAAB8k59ntg4BANNuTHAkjTZBk3pW8pZBD7jWIpZBt8cf65oAT4eDm9euloGCX9NzfF9HwKQxUdEQ15YfeFtkdZAHVpkjL0j4CF0lZCQeuNTBXrvkbtUXC&call_id=1321457495&sig=5f376192b2dd1f5f928f651a996ce757&v=1.0&nonce=9031392668977D4832446065DC3119E7
Stanza sent(response): <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">bWV0aG9kPWF1dGgueG1wcF9sb2dpbiZhcGlfa2V5PTEzNjk3MzQ3NjQxMDg5NCZzZXNzaW9uX2tleT1CQUFCOGs1OW50ZzRCQU5OdVRIQWtqVFpCazNwVzhwWkJEN2pXSXBaQnQ4Y2Y2NW9BVDRlRG05ZXVsb0dDWDlOemZGOUh3S1F4VWRFUTE1WWZlRnRrZFpBSFZwa2pMMGo0Q0YwbFpDUWV1TlRCWHJ2a2J0VVhDJmNhbGxfaWQ9MTMyMTQ1NzQ5NSZzaWc9NWYzNzYxOTJiMmRkMWY1ZjkyOGY2NTFhOTk2Y2U3NTcmdj0xLjAmbm9uY2U9OTAzMTM5MjY2ODk3N0Q0ODMyNDQ2MDY1REMzMTE5RTc=</response>
And the server returns:
<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>
I don't know where the problem is, it looks right to me, but there is no way to authenticate. Does anybody knows if there is any way to debug with the server the reason for the failure? May it be that the App is not yet in the App Store?
If someone can help it would be very welcome!
Since no one responded and someone else can get tricked by this same error due to the fact that this code appears on some examples about Facebook Authentication- I will post the response myself.
Everything is almost ok, it only requires the tag session_key to be changed for access_token in the signature1 string and in the response2 string.
I am working on jersey restful webservices(Java).
I want to upload or send a file to server using restful webservices.
Please help me out on this?
First of all you have to explore such terms as HTTP query structure, Multipart MIME type etc.
The simplest code with jersey would look like snippet below. It's written in scala, but you should easily get the sense:
#Path("/upload")
class UploadFileResource {
#POST
#Path("/file")
#Consumes(Array(MediaType.MULTIPART_FORM_DATA))
#Produces(Array(MediaType.TEXT_PLAIN))
def processUpload(
#FormDataParam("file") uploadedInputStream: InputStream,
#HeaderParam("Content-Length") length: Int) = {
println("Content-Length: " + length)
}
#GET
#Path("/form")
#Produces(Array(MediaType.TEXT_HTML))
def getFormMurkup() = {
"<html><body><form method='post' action='file' enctype='multipart/form-data'>" +
"<input type='file' name='file' />" +
"<input type='submit' value='Upload' />" +
"</form>" +
"</html></body>"
}
}
On a remote client, I'm trying to create a new list in a sharepoint site. Right now, I'm building a CAML string and sending it via http post to my sharepoint site. I've used this method to update list items and create dws folders, but I can't seem to get AddList to work. I get an error "Remove server returned error:NotFound."
here is my CAML:
string soapEnv =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance" +
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" +
" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soap:Body>" +
"<AddList xmlns=\"http://schemas.microsoft.com/sharepoint/soap\">" +
"<listName>" + listName + "</listName>" +
"<description>" + "A Test list" + "</description>" +
"<templateID>100</templateID>" +
"</AddList>" +
"</soap:Body>" +
"</soap:Envelope>";
return soapEnv;
I send this in an http Post with these settings:
uri = "[my sharepoint site]/_vti_bin/lists.asmx";
WebClient client = new WebClient();
client.Headers["SOAPAction"] = "http://schemas.microsoft.com/sharepoint/soap/";
client.Headers["content-type"] = "text/xml; charset=utf-8";
client.Encoding = Encoding.UTF8;
client.UploadStringCompleted += UploadStringCompleted;
try
{
client.UploadStringAsync(new Uri(uri, UriKind.Absolute), "POST", CAML);
}
catch (Exception ex)
{
MessageBox.Show("Error in upload string async: " + ex.Message);
}
Any ideas? I'm pretty certain it's not an authentication issue since I've used the exact same method in this same program to do the previously mentioned functions. The sharepoint site I'm adding the list to is a test site in which I have full read/write capabilities.
D'oh!
In this part of the soap:Envelope tag: "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance"
I had XMLSchema-instance" instead of XMLSchema\"". I needed that extra parentheses to finish that string...