Can we identify the date on which someone liked my page? - php

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"
}
]
}
}

Related

How to fix "Exceeded asset access limit" error when trying to get the full list of pages (accounts) a user has a role on from facebook graph api

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.

How to get the insights per campaign for multiple campaigns that belong to a specific ad account in a single call

We want to get the insights per campaign for multiple campaigns that belong to a specific ad account in a single call.
I am using the following http call and it returns me the correct insights(reach, impressions and clicks) and other data per campaign for the last 30 days only.
https://graph.facebook.com/v3.3/<ad_account>/campaigns?fields=name,status,insights{reach,impressions,clicks}&access_token=<access_token>
How can I use the parameter date_preset so that I will be able to get the insights(reach, impressions and clicks) and other data per campaign for lifetime?
If there is any other way to get the above insights for lifetime without using the date_preset please do not hesitate to advise me how to get them.
We wanted to let you know that our app is written in php.
Because insights is an edge of the campaign object you can apply some filter parameters via dot on that edge, like this:
https://graph.facebook.com/v3.3/<ad_account>/campaigns?fields=name,status,insights.date_preset(lifetime){reach,impressions,clicks}&access_token=<access_token>
Or, if you want to check Insights with the time breakdown (three months, for example) and also take a look on the lifetime summary you can do it like this:
https://graph.facebook.com/v3.3/<ad_account>/campaigns?fields=name,status,insights.default_summary(true).limit(3).date_preset(lifetime).time_increment(monthly){reach,impressions,clicks}&access_token=<access_token>
{
"name": "Campaign Name",
"status": "Campaign Status",
"insights": {
"data": [
{
"reach": "149599",
"impressions": "291917",
"clicks": "13517",
"date_start": "2019-01-11",
"date_stop": "2019-01-31"
},
{
"reach": "265556",
"impressions": "456458",
"clicks": "7915",
"date_start": "2019-02-01",
"date_stop": "2019-02-28"
},
{
"reach": "233641",
"impressions": "331600",
"clicks": "4671",
"date_start": "2019-03-01",
"date_stop": "2019-03-31"
}
],
"paging": {
"cursors": {
"before": "BFR",
"after": "AFT"
},
"next": "next link"
},
"summary": {
"reach": "660772",
"impressions": "1486924",
"clicks": "32484",
"date_start": "2019-01-11",
"date_stop": "2019-05-06"
}
},
"id": "000"
}
https://developers.facebook.com/docs/marketing-api/insights/parameters#param

sql database design: model attribute has infinite results

I'm currently storing user-generated surveys in JSON files, and am now converting these to a sql database. Regarding this portion of JSON:
"surveys": [
{
"surveyId": 1,
"name": "Landing Page Survey",
"active": true,
"panes": [
{
"type": "question",
"name": "Question",
"head": "Is there anything preventing you from signing up for a free 14-day trial?",
"response": "textbox",
"options": [
{
"data": "Time",
"target": "Response 1",
"placeholder": "",
"list": "f7b3cdeed8"
},
{
"data": "Money",
"target": "Response 1",
"placeholder": "",
"list": "local"
},
{
"data": "I'm not interested",
"target": "Thanks",
"placeholder": "",
"list": "local"
}
],
"button": "Send"
},
{
"type": "response",
"name": "Response 1",
"head": "Thanks for your interest in our product. Enter your email address to have a team member follow-up with you.",
"response": "email",
"options": [
{
"data": "data",
"target": "Thanks",
"placeholder": "Your email",
"list": "f7b3cdeed8"
}
],
"button": "Submit"
},
{
"type": "thanks",
"name": "Thanks",
"head": "Thanks for your feedback!",
"response": "multichoice",
"options": [
{
"data": "data",
"target": "",
"placeholder": "put response here",
"list": "local"
}
],
"button": "Button text"
}
]
The JSON isn't that important, just posting so you can see the idea.. surveys.panes are the questions of the survey. Each survey could have an infinite number of questions in it, so I'm struggling with how to store those.
Originally I was thinking of having a surveys table with columns for the questions, 'question_1_type, question_1_text', etc.. This would work if each survey was limited to an amount of questions (10 for example, so I could create 10 sets of columns). This feels horribly wrong though.
Or is it more correct to create a questions table, and for each question in a survey create a row in the questions table. Link it to the survey table with an id, then when you want to output the survey JSON for an API or whatever, just do a bunch of joins across the survey and questions table.
Also, if a survey question is multiple choice, it could have an infinite number of response options also, so would you have to build a table for those as well? Then for each survey JSON build you'd have to join across the surveys, questions, and question_options table. That seems like a lot of overhead running all the joins..
But as I understand, it's incorrect to store anything but one value in a column (an array for example) as it defeats the relational idea of a sql db.
Very noob question.. I haven't quite wrapped my head around correct database design. Appreciate any help!

Retrieving tasks within teams in PHP

I am trying to develop a web application that can fetch data from Asana and generate custom spreadsheet reports. This wrapper class was very helpful in making things simple.
However, I am having a hard time in writing code that gets me the team/s that a particular task belongs to. Even when I export data as JSON through Asana's web application the 'teams' find no mention. From what I understand, Asana itself does not provide an association between teams and tasks. Please correct me if I am wrong.
But if I am right at my conclusion, is there a workaround I could use? Teams are an important part of my data rendering and I need them to be mapped correctly in my reports that I am trying to generate from Asana. The report I want to generate would be hierarchical in nature.
Organisation
Team
Projects
Tasks
Subtask
Can I do something to achieve this hierarchy? The only place I get stuck is getting the projects under a particular team.
Glad to hear that you found that wrapper useful. We will be releasing a PHP Library ourselves soon that you may be interested in. Stay tuned!
Below is some pseudo-code to derive the hierarchy you are looking for, I think. Let me know if it helps.
GET /workspaces
{
"data": [
{
"id": 1234,
"name": "Startup Inc"
}
]
}
GET /workspaces/1234
{
"data": {
"id": 1234,
"name": "Startup Inc",
"is_organization": true,
...
}
}
Because is_corganization is true, we can then continue...
GET /organizations/organization-id/teams
{
"data": [
{
"id": 9876,
"name": "Ninja Team"
}
]
}
GET /teams/9876/projects
{
"data": [
{
"id": 5678,
"name": "Stealth Project"
}
]
}
GET /projects/5678/tasks
{
"data": [
{
"id": 8675309,
"name": "Top secret video"
}
]
}
GET /tasks/8675309
{
"data": {
"id": 8675309,
"created_at": "2015-03-25T17:28:59.255Z",
"modified_at": "2015-05-15T03:13:28.754Z",
"name": "Top secret video",
"notes": "https://www.youtube.com/watch?v=6WTdTwcmxyo",
"completed": false,
... # All the task data
]
}
}

PHP parse facebook json

I've search Stack Overflow and Google for an answer but not luck. I'm trying to get the value of each of the locale with php in the following sample (facebook graph api). Any help would be appreciated.
"data": [
{
"id": "123456789/insights/page_fans_locale/lifetime",
"name": "page_fans_locale",
"period": "lifetime",
"values": [
{
"value": {
"en_US": 33975,
"fr_CA": 6906,
"fr_FR": 6105,
"en_GB": 5647
},
"end_time": "2012-03-14T07:00:00+0000"
},
{
"value": {
"en_US": 33992,
"fr_CA": 6906,
"fr_FR": 6107,
"en_GB": 5648
},
"end_time": "2012-03-15T07:00:00+0000"
},
}
First, this fragment is broken. data is a array not a JavaScript object.
Take the correct fragment and analyze data correctly. The best option is:
json_decode();
Here is how to use it.

Categories