I'm currently writing a PHP application.
I noticed something strange when it wasn't returning the persons birthday.
To cut a long story short, when i manually query the graph api, it gives me the full result set (birthday, email etc. included). However, when I run it in my app, it comes back as if i've not sent the access token.
When I manually visit the address it produces:
{
"id": "507665705",
"name": "Ally Dewar",
"first_name": "Ally",
"last_name": "Dewar",
"link": "https://www.facebook.com/alastair.dewar",
"username": "alastair.dewar",
"birthday": "06/22/1990",
"location": {
"id": "113744028635772",
"name": "Greenock"
},
"gender": "male",
"email": "alastair\u0040alastairdewar.co.uk",
"timezone": 1,
"locale": "en_GB",
"verified": true,
"updated_time": "2012-03-11T15:56:19+0000"
}
However, when my application makes the same request (exact same URL), it comes back with
{"id":"507665705","name":"Ally Dewar","first_name":"Ally","last_name":"Dewar","link":"http:\/\/www.facebook.com\/alastair.dewar","username":"alastair.dewar","gender":"male","email":"alastair\u0040alastairdewar.co.uk","locale":"en_GB"}
My instinct says it could be a setting within the facebook app, as it wasn't a problem beforehand.
EDIT: https://developers.facebook.com/bugs/412680422092698?browse=search_4f854dc037a2a5d12811839
Thanks for any advice.
Make sure you ask for all the permissions that you need and also remove the app and start again. Make sure you ddon't cache any of the responses as well.
How do you query the API? Graph Explorer or just manually open the link (graph.facebook.com/USER_ID) and pass the auth token generated by the app? Testing with the Graph Explorer won't help you with your problem as permissions etc are different.
As mentioned by Nobita, code helps. This is as much as I can advise considering the amount of data you're giving us.
Related
I'm using the latest SendGrid PHP API. I can successfully create a Single Send using the API, and easily associate lists the Single Send should go to when it's eventually scheduled (by list ID). When I use the API to then update that Single Send to use different lists, the list changes are not reflected in the SendGrid dashboard - only name changes, etc. The API request is successful in code and when using Postman. SendGrid's API response to the update reflects my changes in what they return back to me. The Single Send is also in "draft mode" when I attempt this. The associated lists in the SendGrid dashboard never change.
API call to Single Send Update Endpoint (PATCH):
https://api.sendgrid.com/v3/marketing/singlesends/3ee0cd4e-62f7-21eb-8ee8-3a2e1ebc21ed
with param:
{
"name": "TESTER 2",
"send_to": {
"list_ids": [
"52ca8ad3f-9db1-4c2x-1f01-85beecbx94c2"
]
}
}
And SendGrid returns (202, successful response code):
{
"id": "3ee0cd4e-62f7-21eb-8ee8-3a2e1ebc21ed",
"name": "TESTER 2",
"status": "draft",
"categories": [],
"send_at": "2021-02-01T19:06:00Z",
"send_to": {
"list_ids": [
"52ca8ad3f-9db1-4c2x-1f01-85beecbx94c2"
],
"segment_ids": [],
"all": false
},
"updated_at": "2021-01-31T22:52:58Z",
"created_at": "2021-01-31T19:07:20Z",
"email_config": {
"subject": "Hello World",
"html_content": "Hello World!",
"plain_content": "Hello World!",
"generate_plain_content": false,
"editor": "code",
"suppression_group_id": null,
"custom_unsubscribe_url": "https://www.example.org/unsubscribe",
"sender_id": 1212111,
"ip_pool": null
}
}
But, the associated contact lists are not updated. Anyone have any suggestions? My only workaround is to simply delete the single send every time and just re-create it. I'm storing their ID's locally so this adds a bit more work on my end, but I'm not sure what else to do.
To anyone struggling with this, hopefully this will save you some time. The problem wasn't with the API at all, but with the SendGrid dashboard. You need to do a hard reload on the Single Send dashboard page to see your changes. The SendGrid dashboard is a SPA. Ugh.
I am trying to get mutual friends from facebook but it is giving me wrong result. The total number of mutual friends count which I am getting is right but when the data is users is not coming
Request
https://graph.facebook.com/v2.8/1744744292507346?fields=context.fields(mutual_friends{name,picture.type(large)})&access_token=access_token
Response
{
"context": {
"mutual_friends": {
"data": [
{
"name": "Gaurav Varshney",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p200x200/15541198_1872071033026134_3669335060573505093_n.jpg?oh=d4a95ee6cdb8d401be06e8f10fbf6d50&oe=59B0C911"
}
},
"id": "1919297771636793"
}
],
"paging": {
"cursors": {
"before": "MTkxOTI5Nzc3MTYzNjc5MwZDZD",
"after": "MTkxOTI5Nzc3MTYzNjc5MwZDZD"
}
},
"summary": {
"total_count": 2
}
},
"id": "dXNlcl9jb250ZAXh0OgGQHYKW1ALzRNZBAkUhMk2uDFtLZBBkzlasCZAq98zEqnPZBjqy7beHZBJZCVZB7STTw6yMnKC0w4qDA05ZBOGQ3RdRoPjfi1cbAmnChBQ1xLYpJuuKrIEZD"
},
"id": "1744744292507346"
}
I am only getting 1 friend since total_count is showing 2 .Can anyone tell me where I am doing wrong?And how can I use paging ??
When try to hit all_mutual_friends
https://graph.facebook.com/v2.8/1744744292507346?fields=context.fields(all_mutual_friends{name,picture.type(large)})&access_token=access_token
{
"error": {
"message": "(#10) To use all_mutual_friends on behalf of people who are not admins, developers and testers of your app, your use of this endpoint must be reviewed and approved by Facebook. To submit this feature for review please read our documentation on reviewable features: https://developers.facebook.com/docs/apps/review",
"type": "OAuthException",
"code": 10,
"fbtrace_id": "HF3ZO8U3eLW"
}
}
There is a lack of documentation about this feature and I had to dig about it. Mainly regarding on how to request that with Graph API.
That's how I'm doing and it is working, with some flaws that I will explain later:
Let's say we have here UserA and UserB. You need to collect the context-id of each of the user and save it on the server side because it must be used later on.
So, UserA connects and want to request mutual friends with UserB which is already connected. What you will need to do is:
UserA FB Graph request using this:
/'{{UserB context-id}}/all_mutual_friends?limit=5000', 'get'
also sending UserA fbaccesstoken
I use the limit 5000 to avoid pagination on the data results.
Now, the flaws:
The all_mutual_friends is giving me some headaches. I may be completely wrong, of course, but I debugged it for days and it seems there are some issues with Facebook when the feature is still in development mode and not public/authorized by FB. Don't know, I need to ask for permission to see that in production.
On my application I realised there are sometimes some mutual_friends are not actually listed and it is not a fault of the script, but probably some users configuration that avoid using this or some facebook problem. IDN.
Anyways, that's the way you should request mutual friends.
Hope it helps.
i just need some help with Twitters' API
I used the sign in with twitter flow to get the tokens needed to make calls to the API, there weren't any problems with the implementation, and so far I have got both oauth_token and oauth_token_secret so I think I have what I need to use the API.
The problem is about the last method which the documentation said about verif credentials, I am supposed to use that GET method to get a json with information about the user which has just logged into twitter by my app, however, Twitter docu doesn't mention anything about what parameters I need to pass or what headers, just the url.
I used php curl to make the calls to the API, do you know what parameters I need to pass to the API to finally get the json?
Here you have the link to the API docu:
https://dev.twitter.com/rest/reference/get/account/verify_credentials
Thanks in advance.
No params, just the 'Authorization' header.
Use the "OAuth Signature Generator" on the link you included to generate a test request and confirm yourself.
You just need to properly sign the request. This provides the context including the user, since it implicitly includes details about your request, the client secret, the user token etc.
$ oksocial https://api.twitter.com/1.1/account/verify_credentials.json
{
"id": 999999,
"id_str": "999999",
"name": "Bobby Bonson",
"screen_name": "xxxx",
"location": "CA",
"description": "...",
"url": null,
"entities": {
"description": {
"urls": []
}
},
"protected": false,
"followers_count": 699,
"friends_count": 631,
"listed_count": 34,
We are building a activity stream kind of website very similar to facebook (in activity feed alone). For loading user's activity feed, we send the request to PHP file through AJAX method. Server file will handle the logic and return back the values as an array in JSON format. I wanted to know, is there any framework available to write the JSON response to HTML elements. Also, the fees are not similar. It will vary according to the type (Photo, Album, Status Updated, Shared, Liked, etc). So i need to load different template view for each of the activity feed. Actions will be common like Share, Comments for all feeds.
Can you please share which will be the best approach to load the content according to the data received. Also the content need to be refreshed periodically. I have pasted the sample JSON response below for reference:
{
"id": "1",
"picture": "",
"link": "http://www.google.com",
"name": "Srini updated status",
"description": "Lorem ipsum",
"actions": [
{
"name": "Share",
"link": "http://networkedblogs.com/hGWk3?a=share"
}
],
"type": "statusupdate",
"created_time": "2011-05-10T18:35:38+0000",
"updated_time": "2012-07-20T10:42:58+0000",
"likes": {
"count": 0
},
"comments": {
"data": [
{
"id": "19292868552_10150189643478553_22286888",
"from": {
"name": "Lorenzo Portillo",
"id": "613727863"
},
"message": "does anyone knows why i get a rhombus and '?' in my app description when I publish in a user's wall, instead of a letter with accent?!?!?!?!?!?",
"created_time": "2012-05-28T13:48:45+0000"
},
"count": 1
}
}
Need help / suggestions on how to design the template according to the json array in javascript. Any comments / code help will be more helpful.
Thanks in Advance,
Regards
Srinivasan.C
Well, if you consider making a very robust app, take a good look at emberjs.
You should also try jquery's (jquery mobile, jquery ui, jquery ajax)
You can create an html output in your php file when you are getting the response from the Facebook API. According to me you can do json operation easily in PHP. By using json_decode you get array and that you can traverse it and build an html as per your requirement.
Hope it helps
I'm looking for a way to list all pages where a given user is an administrator. Is this possible? If so, where should I be looking?
Not sure what you are looking to accomplish. If you want to prompt the user to add your app to a page the are an admin of, you can do it through the javascript SDK. (https://developers.facebook.com/docs/reference/dialogs/add_to_page/)
Otherwise, you need to use FQL to query for the information. (https://developers.facebook.com/docs/reference/fql/page_admin/)
You'll need the manage_pages permission from your user in order to gain access to this information.
Using Facebooks FQL and the Graph API you can make a query to the page_admin table using the uid index to reference your user.
https://graph.facebook.com/me/fql?q=SELECT page_id, type from page_admin WHERE uid=me()
An alternative :
The /me/accounts Graph API endpoint
In the Graph API's documentation under the user endpoint there is details about the accounts connection :
The Facebook apps and pages owned by the current user.
You also need the manage_pages permission from your user here.
Here is a sample output from a call to that endpoint :
https://graph.facebook.com/me/accounts?access_token=ABC
...
{
"name": "Unicorn Ville",
"access_token": "XXX",
"category": "Application",
"id": "123"
},
{
"name": "StackOverflow'em Poker",
"access_token": "YYY",
"category": "Application",
"id": "456"
},
{
"name": "The Official Bausley Page",
"access_token": "zzz",
"category": "Non-profit organization",
"id": "789"
},
...
Note that /me/accounts returns "apps and pages owned by the current user"; As such the results you will get will have to be filtered, removing all the application entries or alternatively extracting only the non "application" values of the category parameter.