I have a problem with graph api.
The call "https://graph.facebook.com/[pageID]" fails with the message
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
I need the full url of the facebook-page. Is there a way to get the url of a page from pageid only?
EDIT: Thank you for tips. The error was, that when the page is not public, that i cannot query infos via graph. Its also not working, when i (admin of page!) call the graph-url...
If you take a look at Page Graph API Reference there is a example url to get information about the page, include the url of the page that you want. The example url request is :
https://graph.facebook.com/19292868552
and the result is :
{
"about": "Grow your app with Facebook\nhttps://developers.facebook.com/ ",
"company_overview": "Facebook Platform enables anyone to build social apps on Facebook, mobile, and the web.\n\n",
"is_published": true,
"talking_about_count": 34563,
"username": "FacebookDevelopers",
"website": "http://developers.facebook.com",
"were_here_count": 0,
"category": "Product/service",
"id": "19292868552",
"name": "Facebook Developers",
"link": "http://www.facebook.com/FacebookDevelopers",
"likes": 1187896,
"cover": {
"cover_id": "10151298218353553",
"source": "http://sphotos-b.ak.fbcdn.net/hphotos-ak-ash4/s720x720/377655_10151298218353553_500025775_n.png",
"offset_y": 0,
"offset_x": 0
}
}
I think in your problem you put the wrong page ID.
Related
I am building a Laravel 5 app to get the facebook page insights for my client. I am using the Facebook PHP business SDK to make calls to the facebook graph API. The problem appears when I try to get the full list of pages a user has a role on. The app was reviewed by Facebook and has manage_pages permission granted (I know there is a pages_show_list permission but in the docs is specified that any of them will work).
The procedure is simple and very similar to this code:
https://github.com/facebook/facebook-php-business-sdk/blob/master/examples/UserAccountsEdge.php
where $access_token is the user access token, not the page access token because the page access token will be sent by the graph API in the response.
I am getting this error from the Graph API:
{
"error": {
"message": "Application request limit reached",
"type": "OAuthException",
"is_transient": false,
"code": 4,
"error_subcode": 1349193,
"error_user_title": "Exceeded asset access limit",
"error_user_msg": "You have exceeded asset access limit for the calling user. For asset type page, there is a limit to 3 instances the app can access for the caller.",
"fbtrace_id": "AnTVYLGrhtjHlL7DgK0zB-A"
}
}
Indeed the number of the items in the accounts (pages) list is limited to 3 and I do not know why. If a user has roles on 20 pages I just can’t get the complete list of those pages.
The errors disappear if I am using the $limit => 3 (or less) field inside the $fields array. In this situation the response of the API looks like this (I deleted the real content to simplify the reading):
{
"data": [
{
"access_token": "...token...",
"category": "...category name...",
"category_list": [
{
"id": "...id...",
"name": "...name..."
}
],
"name": "...page name...",
"id": "...page id...",
"tasks": [
"ANALYZE",
"ADVERTISE",
"MODERATE",
"CREATE_CONTENT",
"MANAGE"
]
},
{
"access_token": "...token...",
"category": "...category name...",
"category_list": [
{
"id": "...id...",
"name": "...name..."
}
],
"name": "...page name...",
"id": "...page id...",
"tasks": [
"ANALYZE",
"ADVERTISE",
"MODERATE",
"CREATE_CONTENT",
"MANAGE"
]
},
{
"access_token": "...token...",
"category": "...category name...",
"category_list": [
{
"id": "...id...",
"name": "...name..."
}
],
"name": "...page name...",
"id": "...page id...",
"tasks": [
"ANALYZE",
"ADVERTISE",
"MODERATE",
"CREATE_CONTENT",
"MANAGE"
]
}
],
"paging": {
"cursors": {
"before": "...",
"after": "..."
},
"next": "https://graph.facebook.com/v3.3/...id.../accounts?access_token=...token..."
}
}
I tried to use cursors, implicit fetching and iterations ( foreach, $cursor->rewind(), $cursor->next() ) to get previous / next items from the list but still no success. The limitation of 3 items in the accounts (pages) list cannot be exceeded. Has anybody encountered this problem and found a solution to it? I have spent many hours to search in the facebook developers docs for a solution or an explanation of this kind of rate limiting but found nothing related to this.
I have also used the Graph API Explorer to test the calls and the result is exactly the same.
Is there any API or anything which provides city,state and country name when pincode is given.Please share if you have any solution
Thanks in Advance
Hello. there are many more sites which provides this kind of
information i will show you two of them.
Third Party API
Google API
try this url with your pincode. this will gives you data in json format like below one. i have removed some of data to show you so it was not exactly as per return response of third party api.
{
"Message": "Number of Post office(s) found: 1",
"Status": "Success",
"PostOffice": [
{
"Name": "I E Bapunagar",
"Description": "",
"BranchType": "Sub Post Office",
"DeliveryStatus": "Delivery",
"Taluk": "Ahmadabad City",
"Circle": "Ahmadabad City",
"District": "Ahmedabad",
"Division": "Ahmedabad City",
"Region": "Ahmedabad HQ",
"State": "Gujarat",
"Country": "India"
}
]
}
check it, and if you want any help,you can ask.
Use the GeoCoding API
For example, to lookup zip 626134 use a request like this:
http://maps.googleapis.com/maps/api/geocode/json?address=626134&sensor=true
There is a discussion here: location (lat long) using facebook api but it doesn't show how to get it...
I can get the basic info:
"location": {
"id": "104146386288393",
"name": "Newton, Massachusetts"
},
but how to I make a request using the location ID to get
{
"id": "104146386288393",
"name": "Newton, Massachusetts",
"picture": "http://external.ak.fbcdn.net/safe_image.php?d=AQDygUYzFOcjhDoD&w=100&h=300&url=http\u00253A\u00252F\u00252Fupload.wikimedia.org\u00252Fwikipedia\u00252Fen\u00252Fe\u00252Fe6\u00252FNewton_City_Hall\u0025252C_Massachusetts.jpg&fallback=hub_city&prefix=s",
"link": "http://www.facebook.com/pages/Newton-Massachusetts/104146386288393",
"likes": 3741,
"category": "City",
"is_published": true,
"is_community_page": true,
"description": "<snipped data>",
"location": {
"latitude": 42.3369,
"longitude": -71.2097
},
"checkins": 310,
"talking_about_count": 8912
}
Here is my code for facebook:
$user_profile = (new FacebookRequest($session, 'GET', '/me?fields=id, first_name, location'))->execute()->getGraphObject(GraphUser::className());
thanks
This is what you can do:
Authorize the user with user_location
Make a GET request to /me?fields=location
Make a GET request to the location id you get in the result of /me
...meaning, you just need to do an extra API call to get latitude/longitude.
You can check with the graph api tool before implementation.
After having location id, you need to call "location_id"?fields=location to get long/lat
When i create an event with the graph api i need to specify the venue and i would like also to show the map.
I do
$fb_event['name'] = "THis is to test latitude";
$fb_event['description'] = "And longitude!!!!";
$fb_event['start_time'] = date( "c", Ai1ec_Facebook_Event::get_facebook_start_time($event->start));
$fb_event['location'] = "Where you want";
$fb_event['street'] = "Via andrea del sarto 9";
$fb_event['city'] = "Milan";
$fb_event['latitude'] = 45.444975793404;
$fb_event['longitude'] = 9.2119209654715;
$facebook = $this->facebook_instance_factory();
try {
$result = $facebook->api( "/me/events", "POST", $fb_event );
} catch (FacebookApiException $e) {
fb($e);
}
This produce this event which show the correct street and city, but no map. If i edit the event and save, the map "Magically" appears using the street and city correctly.
In any case latitude and longitude are ignored.
What am i doing wrong?
If you compare your two test events in the Graph API explorer you'll see that Event ID 239298922846828 does not have its latitude and longitude populated, while 245655182207213 does. I'm assuming 245655182207213 is an event you've edited.
Looking at your code, you seem to be doing everything as described in the documentation. However, I've found that what is described does not always work.
What I've been seeing is that events populated from within Facebook that occur at a known venue are no longer allowing you to specify an address. Instead all they save is a venue id within Facebook which you can then drill into to get the address, etc.
Take a look at one of my events. For this event, there is no way to edit the details of this location from within Facebook, nor does the event venue details get returned with an API call. I'm using the API to pull the event details to an external website. This change caused me days of frustration.
I started seeing this behavior in late April. I haven't found any official documentation announcing this change.
When some documentation appears, what I expect the new event venue workflow will be is something like:
Query the area where your event will take place to see if a venue exists already.
If yes, get save its id.
If not, create a new community page for your venue and save its id.
Use this ID to populate the event venue.
In the end this is a known facebook bug
https://developers.facebook.com/bugs/173095916131752
Two different formats when create using the same parameters.
When create event through gql
{
"id": "xxxxxxxxxxxxxx",
"owner": {
"name": "xxxxxxxxxx",
"id": "xxxxxxxxx"
},
"name": "W1112",
"start_time": "2013-10-22",
"is_date_only": true,
"location": "Tulsa, OK, United States",
"venue": {
"latitude": 36.131388888889,
"longitude": -95.937222222222,
"street": "",
"zip": "",
"id": "109436565740998"
},
"privacy": "SECRET",
"updated_time": "2013-09-19T12:23:26+0000"
}
When create event through fb
{
"id": "xxxxxxxxxxxxxx",
"owner": {
"name": "xxxxxx",
"id": "xxxxxxxx"
},
"name": "1234",
"start_time": "2013-10-09T21:26:00+1100",
"end_time": "2013-10-25T00:26:00+1100",
"timezone": "Australia/Sydney",
"is_date_only": false,
"location": "Maroubra Junction",
"venue": {
"latitude": -33.940804216453,
"longitude": 151.23876752992,
"city": "Maroubra",
"state": "NSW",
"country": "Australia",
"id": "153993547968514",
"street": "832 anzac Parade ",
"zip": "2035"
},
"privacy": "SECRET",
"updated_time": "2013-09-19T10:50:14+0000"
}
How can we identity the date on which someone liked my page.
is there any way where we can identify the date on which someone liked my page ?
No. You can't even get a list of people that like your page, so you can't get a date they liked it. The only information you can get is how many people like it.
You can view a chart of how many people liked your page over time at Facebook Insights.
Well no, You can make a graph call to the statuses and feeds of a user with valid access_token to get the id and name of the people who liked the post.. The timestamp can be found for the comments though ..
{
"id": "257821xxxxxxx",
"from": {
"name": "Maxxxxxx",
"id": "100xxxxxx"
},
"message": "incredible ..",
"updated_time": "2011-09-15T11:21:15+0000",
"likes": {
"data": [
{
"id": "6xxxxxx6",
"name": "Axxxxxxxxxa"
}
]
},
"comments": {
"data": [
{
"id": "257xxxxxxxxxxxx904",
"from": {
"name": "Maxxxxxxxxxxal",
"id": "1xxxxxxxxxxxxxx"
},
"message": "htxxxxxxxxxxxxxxxxxxxxxxxxxx",
"can_remove": true,
"created_time": "2011-09-15T11:22:06+0000"
}
]
}
}