I am looking for a fairly simple way of obtaining pictures from Facebook. I have a client that has pictures that he uploads to Facebook quite often. He wants a way for those pictures to be populated on the website that I built for him a while ago. I thought doing it with google drive would be a fairly easy solution for him, but it has not been.
I am trying to create a simple page that grabs his folders that the images live in with the graph api, without having to do a lot or having users logged in. What is going to be the easiest way of doing this?
I tried the explorer for the api and have the following code.
<?php
$request = new FacebookRequest(
$session,
'GET graph.facebook.com',
'/me',
array(
'fields' => 'id,name,photos{album}'
)
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
?>
I for now would just like to be able to echo the elements so that I can learn how it works, after that I can refine it. What am I doing wrong?
Related
I need to create an admin panel of sorts for a client that will present him with data of conversion values over specific time intervals, for his eshop which has the New Facebook pixel installed.
Assume I've properly configured the Standard Event I want to track. The part where I'm stuck is actually reading the data via the Facebook Marketing php sdk. It is supposed to look something like that:
/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
$session,
'GET',
'/{ads-pixel-id}/stats'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
Am I looking at the right place? Can I still get these kind of stats or is this behavior deprecated? The Facebook documentation isn't very clear on this and everywhere I look I see deprecated pages and code,
You need to add an aggregation like this:
/{ads-pixel-id}/stats?aggregation=event
I have setup a facebook app to post images / videos to one particular fan page. It requests 'publish_actions' and 'manage_pages permissions. It is in developer mode and I have no intention to expand the functionality beyond posting to this single facebook page.
The code works correctly, it posts to the correct page and everything looks good whilst logged into the developer account / page admin (same account). But other facebook users cannot see the posts that have been made via the app. I was under the impression that apps didn't need to go through the review process for internal apps such as these?
Heres a quick stripped down version of the code for posting to the page:
FacebookSession::setDefaultApplication($settings['app_id'], $settings['secret']);
//This is user access_token not the pages.
$session = new FacebookSession( $settings['access_token'] );
$pageTokenResponse = (new FacebookRequest(
$session
, 'GET', '/' . $settings['page_id']
, array( 'fields' => 'access_token' )
))->execute()->getGraphObject(GraphPage::className());
//Retrieved Page Token
$pageToken = $pageTokenResponse->getProperty("access_token");
uploadUrlToFacebook($imgurl, $item->get_title(), $session, $pageToken, $settings['page_id']);
function uploadUrlToFacebook($url, $title, $session, $pageToken, $pageId){
$request = new FacebookRequest(
$session,
'POST',
"/$pageId/photos",
array (
'access_token' => $pageToken
,'url' => $url
,'message' => $title
)
);
$response = $request->execute();
}
I'm sure there is a stupid error either somewhere in the code or my apps setup but why can I see the posts but nobody else can ?
Turns out I had already selected some items for review before I properly understood the process so I ended up in a state of not being able to make the app live as I had pending review items. I deleted the permissions from the review queue, made the app live and all is good.
I think while authenticating Fb App you given "only me" visibility for Publish Actions.
go to https://www.facebook.com/settings?tab=applications
Select your App .
Then Check this . "App visibility and post audience"
I am using the following to make my requests to Facebook
$facebook->api('/feed',
array(
'access_token' => $_SESSION['fb_access_token'],
));
However, I want to get the news feed of the user.
Not to be confused: I do not want the feed of a certain user, much less of a given page.
I want the News Feed/Feed Stream the user views when accessing Facebook, one that contains the posts of your friends, etc.
How is this possible?
Make an API call to /me/home or /user_id/home where user_id is the current session user.
You are also using the old PHP SDK
/* PHP SDK v4.0.0 */
/* make the API call */
$request = new FacebookRequest(
$session,
'GET',
'/me/home'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
Reference: https://developers.facebook.com/docs/graph-api/reference/v2.2/user/home
UPDATE:
The latest Graph API doc suggests the following:
As of October 6th, 2015, this endpoint is no longer available. Please consider using the /user-id/feed edge instead.
This effectively means we cannot access the user news feed provided by Facebook but will have to rely on /user-id/feed as an alternative.
The endpoint is me/home.
https://developers.facebook.com/docs/graph-api/reference/v2.2/user/home
The posts that a person sees in their Facebook News Feed.
Getting all recent notifications including read via Graph API, call:
graph.facebook.com/USER_ID/notifications?include_read=true
Hi guys i've searched a lot here on stackoverflow but i'have not find a solution for my problem.
I'm building a (University) project , this project aims to do some operation (like sentiment analysis) on a user statuses.
I'm using Facebook PHP SDK , and after login i can get some of my Statuses with this code :
$request = new FacebookRequest(
$session,
'GET',
'/me/statuses'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
var_dump($graphObject);
Now the problem is that with this code, i get something like ~20 of my statuses, and at the very bottom of the response i got the paging links (previous or next) for get ~20 more statuses.
There is a way to get all my posts from the first? Or some trick to get that?
Thanks in Advance Nico.
So I have a friend who is a musician and has a page set up. He has asked me if there is a way of getting all the events on his Facebook Page via the Graph API and then putting them onto his website. I said I'd look into if this is even possible given that the API is now at version 2 and the PHP SDK has been bumped up to version 4.
Does anyone know how I'd do this? I already know how to make 'GET' request using the new PHP SDK, however I don't seem to be able to get the necessary fields.
Any help would be great!
Thanks!
It's given on developers.facebook.com
/* make the API call */
$request = new FacebookRequest(
$session,
'GET',
'/{page-id}/events'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
More at https://developers.facebook.com/docs/graph-api/reference/v2.0/page/events
Hope this Helps.