RestFB: How to get page likes? - restfb

I'm trying to retrieve the number of likes a facebook page has.
Here's my code:
FacebookClient fb= new DefaultFacebookClient(tok, appSecret);
Page page = fb.fetchObject("178697151159", Page.class, Parameter.with("likes", "true"));
System.out.println("My pages likes: " + page.getLikes());
but, its giving null as output.
I'm new to restFB. So please help me in getting this.
Thank you.

try this:
FacebookClient client = new DefaultFacebookClient(token, Version.VERSION_2_6);
Page page = client.fetchObject("178697151159", Page.class, Parameter.with("fields","fan_count"));
System.out.println("My page likes: " + page.getFanCount());
You have to tell Facebook which fields (fan_count) you need and you should use the newest API (2.6).
Then the rest is very easy :)

Related

Looking to get the full site URL

I am looking to get the current site url in my apex class. I want the whole url, not just the domain Instead of https://google.com/ can it be something like https://google.com/page?something=something
I could only find how to put the domain without the full link. Thanks for your help in advance
To get the current URL of the Visualforce page you can use
PageReference pageRef = ApexPages.currentPage();
string currentUrl = pageRef.getUrl();
// Get or set query string parameters
string param1 = pageRef.getParameters().get('param1');
This only works in Visualforce.
When using Lightning, you should pass any additional parameters to the apex controller you need. You can use this JS to get the current page URL to send to the apex controller.
let currentUrl = window.location;
PageReference documentation

Fetching the weather data of the place and set in flatlist

I'm new in react native i'm making a dummy project on fetching the weather of the place in flatlist. I downloaded one project from github But i'm getting blank screen in my real device and emulator as well the link for the github repository is:-
https://github.com/andrewsmith1996/geolocationWeatherReactNative
Any help will we appriciated
First add this to your AndroidManifest.xml file
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Second in the URL you have to add your access key
let url = 'https://api.openweathermap.org/data/2.5/forecast?lat=' + this.state.latitude + '&lon=' + this.state.longitude + '&units=metric&appid=YOUR_KEY_HERE';
if you don't have the key then for this example to work use this url.
let url = 'https://samples.openweathermap.org/data/2.5/forecast?q=M%C3%BCnchen,DE&appid=b6907d289e10d714a6e88b30761fae22';
You will get something like this: https://i.stack.imgur.com/u250N.png

is that possible to send header information in $window.open(url) method

I am downloading the file from the server using API, for that i have to send session details in header, how can i do it using angularjs?. Please help me out.
Thank you in advance for suggestions.
No - It is not possible to send headers in straight way using $window.open
Yes - Its is possible but not straight way, If you've got server-side control then you can set header value in query string and get it parsed from query string on the back-end.
I don't suggest to pass params with window.open.
BUT you can use window.open like this.
var params = {
access_token: 'An access_token',
other_header: 'other_header'
};
//Add authentication headers in URL
var url = [url_generating_pdf, $.param(params)].join('?');
//Open window
window.open(url);
Please check the details info here

Linking Data in Firebase

I am designing a forum and have a layout like this in on my Firebase:
root
|-posts
|-postID1
|-creator: "userOne"
|-creatorUID: "simplelogin:1"
|-text: "Some Text"
|-postID2
|-creator: "userTwo"
|-creatorUID: "simplelogin:2"
|-text: "Some Other Text"
|-profile
|-simplelogin:1
|-firstName: "John"
|-user: "userOne"
|-simplelogin:2
|-firstName: "Sue"
|-user: "userTwo"
On my forum page. I simply use a Angular ng-repeat to get all of the posts on Firebase and list them out. I also want to print out the first name of whoever created the post, but right now, I can only access {{ post.creator }}, which just gives the username of the person who posted. How can I link the post's creator (or creatorUID) with the first name field of that person's profile?
If you're just displaying the the users firstName I would place the users name in the postIDX object.
This would be quicker and produce less requests to Firebase with you going back and fourth with each post to get the usersFirst name.
more information on structuring data and best practices can be found here: https://www.firebase.com/docs/web/guide/structuring-data.html
Updated from response
if you wanted to get the user details then within every request to the postIDx you'd need to do something similar to this (not tested and quick mock up).
var fbRef = new Firebase('firebase path'),
postDetailsObject = {};
fbRef.child('posts').once('value', function(snapshot) {
// loop through each post
snapshot.forEach(function(childSnapshot){
var postDetails = childSnapshot.val(),
profileDetails;
postDetailsObject.post = postDetails;
fbRef.child('profile/' + postDetails.creatorUID).once('value', function(profileData) {
postDetailsObject.profile = profileData;
});
})
});
Then return the postDetailsObject in to angular so you can loop through the single object.

Show Filtered Lookup in CRM2011 from Silverlight Grid

I recently show up all products on a "Lookup" Field on a Inline Silverlight App on the CRM2011 Quote form.
I do this with directly calling the link of the Lookup:
var uri = (ScriptObject)crmUri.Invoke("create", string.Format("/_controls/lookup/lookupinfo.aspx?LookupStyle=single&objecttypes={0}", objectType));
var dArgs = (ScriptObject)HtmlPage.Window.CreateInstance("Object");
dArgs.SetProperty("items", new string[] { "" });
dynamic dlgResult = HtmlPage.Window.Invoke("showModalDialog", uri, dArgs, "dialogWidth:500px;dialogHeight:700px");
Our Customer wants to filter the lookup view on a value of a specific field on the product form.
This field is a optionset and can be 1 or 2.
I tried to add "&$filter=" + "producttypecode/Value" + " eq 1" or "&$filter=" + "producttypecode" + " eq 1" in the link, but this always Returns a error message.
Are there any suggestions?
This is a valid request that I just tested.
ProductSet?$filter=ProductTypeCode/Value eq 1
If that doesn't work I'd recommend the following troubleshooting steps.
Test your full URL in a browser first.
If it works in a browser then fire up fiddler and see what the difference is between the silverlight request and your manual request using a browser.
If you are having difficulty determining the correct full url I'd recommend downloading and becoming familiar with the CRM OData Query Designer. It will allow you to use a GUI to generate your request strings, and test them out. It can be found here.
http://crm2011odatatool.codeplex.com/
We solved this issue by adding a new System View and call it from its URL.

Resources