facebook pagination next url giving empty set of friend list - facebook-graph-api

i am using following code to get all my friends ,but it gives only 5 friends in data and next pagination link,i have 22 friends but when i click on next pagination gives empty array data
FB.api('/me/friends/?access_token=CAACEdEose0cBAIgrQyQs6DaApZAwDCpSub2WHKXaU3inS1QPvcep24avZCoVpyYcHoWgZBltVdFKbKy8UokU6x2JXGEgeDcRu3C3sM2dEZCuzQIsbZALFGPcamyRqR5ZA4VE8c0U2KNcKNar5qVzo9ToAr6BQatoJKd4dIiXg3dqoS4RLlszQjfm3Yf66XxtKxPyIHEDhudQCLgBZCcINLlucERa4ZBf9a8ZD',function(response) {
console.log(response);
if (response && !response.error) {
var nextPage = response.paging.next;
FB.api('v2.1/248176728710033/friends?limit=10&access_token=CAACEdEose0cBAIgrQyQs6DaApZAwDCpSub2WHKXaU3inS1QPvcep24avZCoVpyYcHoWgZBltVdFKbKy8UokU6x2JXGEgeDcRu3C3sM2dEZCuzQIsbZALFGPcamyRqR5ZA4VE8c0U2KNcKNar5qVzo9ToAr6BQatoJKd4dIiXg3dqoS4RLlszQjfm3Yf66XxtKxPyIHEDhudQCLgBZCcINLlucERa4ZBf9a8ZD&offset=10&__after_id=enc_AeysBhpBnD6OYeeb4OHHT4qPay7GeUF8OUqNU7PcF3HilkONx4E5EXzymARn2J3u7msA2J4PqjbJyyCE51vHJCOX',function(resp){
console.log(resp);
});
}
//
});

It is not possible to get ALL friends anymore, see my answer in this thread: how to get a list of all user friends (not only who use the app)?
If you still get friends who aren´t using your App, it could be because your App was created before end of April 2014. In that case, it´s a v1.0 App. Your are using /me/friends without a version tag in the first call, but with a version tag in the second call. Also, use /me instead of that id (248176728710033).

Related

I m inserting my data uthrough page item using request process it gives an error fetch more then one row please give me a solution

var a = $v('P1995_LUMBER');
if ((a = '1')) {
apex.submit({
request: "CREATE",
set: {
LUMBER: "P1995_LUMBER",
LST_NME: "P1995_LST_NME",
FST_NME: "P1995_FST_NME",
},
});
} else if (a != '1') {
apex.submit({
request: "Update",
set: {
LUMBER: "P1995_LUMBER",
LST_NME: "P1995_LST_NME",
FST_NME: "P1995_FST_NME",
},
});
} else {
alert("bang bang");
}
Couple of things:
JavaScript's equality check is either == or === (more details here). (a = '1') assign '1' to the variable.
It seems like you're not using the apex.submit process correctly. Typically, you would set the item's value
e.g.:
apex.page.submit({
request: "SAVE",
set: {
"P1_DEPTNO": 10,
"P1_EMPNO": 5433
}
} );
Although, by looking at your JavaScript code, I would say you don't even need to use JavaScript.
Whenever you submit a page, all items on it are automatically sent to the server-side. You can then reference them using bind variables. You could then simply have two process, one for the Create and one for the Update, each having the corresponding insert/update statement using the different items on your page.
Usually what you will see is a page with two buttons for Create/Edit. They will have a server-side condition so that only the correct one is displayed.
Try creating a Form type page (form with report) using the wizard, and you'll see how everything is done.
Without seeing the page and the code you're using it's hard to tell what your issue really is, more details would be required.
That code does not have any sql in it so it is impossible to diagnose why you are encountering a TOO_MANY_ROWS exception. Run the page in debug mode and check the debug data - it should show you what statement is throwing the exception. If you need more help, post a proper reproducible case, not a single snipped of code without any context.

Id returned in one device is not matching with the other?

I trying to get my friends on facebook using graph api. But My id is showing different in both desktop and my phone. I am working on Ionic 2, and I need to get my friends using android phone. By using the id generated by desktop I am getting some friends. But with the id generated by phone, the list of friends is empty. How to resolve this?
here is my code
fbGetDetails() {
Facebook.getLoginStatus().then(response => {
if(response.status == "connected"){
Facebook.api("/" + response.authResponse.userID + "/friends", []).then(res => {
alert("Total friends = " + res.summary.total_count);
alert(response.authResponse.userID);
if(res.data.length){
alert("Authorized friends = " + res.data.length);
for(var i=0; i<res.data.length; i++){
this.friends[i] = res.data[i];
// Facebook.api("/" + this.friends[i].id + "/picture", []).then(resp => {
// this.friends[i].picture = resp.data.url;
// })
}
} else{
alert("None of your frieds are using this app");
}
});
}
})
}
In the above code authResponse.userID will be the generated id. Actually, I was logged in desktop and checking in the graph api explorer. It is showing one of my friend.
But even when I mention in the above code "/me/friends" instead of "/" + response.authResponse.userID + "/friends" also I am getting no friends in my phone.
You are probably using a different App for desktop and ionic. IDs are "App Scoped", so you get a different one per App. Also, you can only get friends who authorized your App with the user_friends permission too.
Btw, you can just use /me/friends instead of /user-id/friends.

Nested pagination in facebook graph api while using php-sdk-v4

I am trying to get all users who likes a specific post on a feed. I am using facebook/php-sdk-v4 . There is no problem on getting next page for feed. However when I use next function to get next users who liked that post in inner loop it gives
Error:Caused by: Facebook\Exceptions\FacebookAuthenticationException
Subfields are not supported by feed.
In FacebookRequest.php I disabled appsecret_proof, maybe it is related to this security issue. If I don't disable, it gives now invalid appsecret_proof despite v5.0 sdk already generates appsecret_proof internally at the line 70 of Facebook\Authentication\AccessToken.php.
Without appsecret_proof I am able to request but in some cases like batch query or loops I think there is a need for appsecret_proof. However, it generates that code itself and it gives invalid error. I don't know what to do.
$fb = new Facebook\Facebook([
'app_id' => '60...
]);
$feed = $graphNode->getField('feed')
while(true) {
foreach ($feed->all() as $key1 => $post) {
if ($likes = $post->getField('likes')){
while(true) {
if (!($likes = $fb->next($likes))) break;
}
}
}
if (!($feed = $fb->next($feed))) break;
}

How to re-init Facebook

I use the FB Javascript API to create Like-buttons. The button appears in the lightbox-view of an image based on lightbox2 (http://lokeshdhakar.com/projects/lightbox2/)
I create once a div with an id
.append($('<div/>', {
"id": 'fb-image-like', "data-send" : 'false', "data-layout" : 'button_count', "data-width" : '250', "data-show-faces" : 'true', "data-colorscheme" : 'dark', "data-font":'arial'
}))
on lightbox's "build"-event. On "updateDetails" (Show next image) I set the data-href-attribute, append the "fb-like"-class and start window.fbAsyncInit();
$('.fb-like').removeClass("fb-like");
//FB._initialized = false;
$("#fb-image-like").attr("data-href", url).addClass("fb-like");
window.fbAsyncInit();
Facebook creates the iframe with Like-button and everything works perfectly. On next image the generated code looks good (replaced data-href) but the Like-Button appears as already liked, because the URL in like.php doesn't change. The window.fbAsyncInit(); doesn't re-init the session. If I dislike now, the last image will be disliked. What can I do, to re-init the Facebook-session completely?
The window.fbAsyncInit(); doesn't re-init the session.
Of course it does not, because that’s not it’s purpose at all.
Just call FB.XFBML.parse again (probably with a scope parameter), to have it re-parse your like button tag.

Redirect Entry form in SharePoint back to itself once entry submitted?

The issue I have is that people in my group are using a link to an Entry Form to post new itmes to a SharePoint list. Everytime they click 'submit' to post new item, SharPoint redirects them to the list.
I need a solution for SharePoint to direct them to the empty Entry form instead, no matter how many times they need to use it.
Is there such solution? Thanks,
I already have this "/EntryForm.aspx?Source=http://" in the link to the Entry form, but works only 2 times, after that will direct to the list.
Essentially you need to ensure that the Source parameter is always set to EntryForm.aspx so that no matter how often you loop through the form you always get redirected back to a new one at the end. You knew this, but I am just clarifying!
Simplest method would be some javascript to test this source parameter and if its not what you want then redirect the request so it is.
If you can edit the EntryForm.aspx page in SharePoint Designer then add this javascript to the page somewhere:
<script type="text/javascript">
if (gup("ok") != 1) {
if (gup("source") != window.location.href) {
window.location = window.location.href + "?&source=" + window.location.href + "&ok=1";
}
}
function gup( name ){
//This function returns the URL parameter specified
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
</script>
Essentially this is just redirecting your requests to this page so the source is always itself. The ok parameter is just to ensure that it only does it once.
This is not perfect code, but it demonstrates the idea (and it works!)
gup (Get URL Parameter) function is taken from here and I find it really useful.
Hope it helps
Charlie