I tried to use the parser to pull in the feed of a Facebook page and it returned a 400 error code. Looking that up on Google, it appears it is an authentication error. Does some type of Facebook app authentication need to be implemented before trying to pull in this type of feed? How would I implement that authentication?

Thanks,
Ben

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rashad612’s picture

I think it doesn't work with all profiles. Because it is not a registered app. Maybe the public profiles only.

BenK’s picture

Actually, I've tried both profiles and community pages that are public, but I still get the 400 Error. Any other ideas? I've tried bunches of IDs and I get the 400 error no matter what. Do you have a profile or community page Id that actually works for you that I can test out? What is the link you're using?

--Ben

rosemberg’s picture

Hi BenK,

I'm with the same problem. Have you managed to solve this? I'm wondering if the problem is related on how Feeds handles tokens.

Well, if anyone could help...

Thanks in advance.

rashad612’s picture

@rosemberg: do you use app and its access token in your URL ?

rosemberg’s picture

Hi @rashad612,

That was the problem! I wasn`t using the access token correctly in the command line (URL) to gather the feed. Now I registered my app (website) and got the app secret and thus, the access token.

Thanks for the attention,
Rosemberg

rashad612’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

TomSherlock’s picture

Hi rosemberg. Do you think you could give some more details?

I've used Feeds before for BoingBoing and other RSS feeds. This is first time I'm using it for FB.

I've successfully established an app id and have used it successfully with the FB social module.
But there doesn't seem to be a field where I can enter the app id for the Facebook parser.

Thanks.

ainbritain’s picture

I'm having a similar problem as TomSherlock.

I can get a token using info from my app and this query:
https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&clie...

This token works fine for me with feeds, and successfully adds nodes as expected when in the Feed field I add &access_token=MY_TOKEN to the feed URL.

However, according to my understanding of the Facebook API, tokens expire in 60 days! My site aggregates events feeds from 20+ different groups, so how can I avoid having to change the token on 20+ Feeds content posts every two months?

Ideally I want to be able to generate a new access token every month or so, using my app id and app secret. Does this require a different Feeds fetcher? I've tried hacking the httpget fetcher, but I can't figure out how to append text to the url (I get a type error, object cannot be converted to string.) I don't know how to make my own fetcher, I'm new to PHP and to Drupal.

It's trivial to get an access token in PHP alone, but I don't know how to plug this in to Feeds:


    $app_id = "YOUR_APP_ID";
    $app_secret = "YOUR_APP_SECRET";
    $app_token_url = "https://graph.facebook.com/oauth/access_token?"
        . "client_id=" . $app_id
        . "&client_secret=" . $app_secret 
        . "&grant_type=client_credentials";

        $response = file_get_contents($app_token_url);
        $params = null;
    parse_str($response, $params);

    echo("This app's access token is: " . $params['access_token']);

 

Any help is greatly appreciated! Thank you!
Also please correct me if I'm infringing on any Drupal Issues etiquette, I'm new here.

azin’s picture

Category: support » feature
Status: Closed (fixed) » Needs work

+1 for @TomSherlock's request, this issue is far from fixed unless the module allows users to add their Facebook APP ID and secret on Facebook Parser settings page, and periodically regenerate the access token.

Facebook expires Access Tokens regularly and this module is quite unusable if one is aggregating a number of pages, where imports may quit suddenly.

azin’s picture

Category: feature » bug
Priority: Normal » Major

Indeed this module cannot be used unless the Facebook auth issues are addressed, re-opening this issue.

abdul.muiz.meer’s picture

Hi everyone,
I have managed to make some additions to the module to make it work(asking user for only App ID and App Secret in configuration and module gets access token itself). I have used the code in #9 to get access token.
Can anyone tell how can i make changes to the current module or should i make another project/module for this?

rashad612’s picture

Please post your changes as a patch here, so that we can apply it to the module.

abdul.muiz.meer’s picture

I don't know how to create a patch. I can upload files that i have created/edited and you check weather they are according to Drupal standards or not and update your module.
Should i do this?

abdul.muiz.meer’s picture

FileSize
9.13 KB

Here is the ziiped folder i have made some changes in .module file and added new feedsfacebookfetcher.inc file.

artofeclipse’s picture

@abdul.muiz.meer I will handle this from here thank you :)

abdul.muiz.meer’s picture

You are welcome...:)

artofeclipse’s picture

Status: Needs work » Needs review

The issue will be solved once you use the following URL structure

https://graph.facebook.com/APP_ID/feed?access_token=YOUR_APP_ACCESS_TOKEN

and it should be https protocol not http.

I test this and it worked on my local machine, if you have any other questions please reply on issue.

abdul.muiz.meer’s picture

I did make this URL when user submits Api key and secret.
There is a new fetcher (Facebook fetcher) in list of fetchers, which you need to select and than pass url like "http://graph.facebook.com/{id}/feed" along with api key and secret in seprate textboxes (made available by fetcher) and rest of the work is done by fetcher.

artofeclipse’s picture

@abdul.muiz

I checked your code, it need some cleanup I will commit it today :) but for now using the access token key in the URL fix this issue, thank you for you effort :)

pinkonomy’s picture

Where can I see these separate textboxes?I cannot see them.
I can only see an HTTP fetcher and a File upload featcher without textboxes.Am I missing something?

abdul.muiz.meer’s picture

@pinkonomy Have you downlaoded module from comment #15?

pinkonomy’s picture

Ah sorry,will try that,thanks

RobertInOP’s picture

I have tried both using all the files from #15, and just the .module and the FeedsFacebookFetcher.inc files. Either way, I'm not seeing a new Facebook fetcher, only the same HTTP and file upload ones as in #21. Maybe I'm missing something?

edit: Maybe I did miss something, not sure what. But, now I do have the Facebook fetcher. After switching to that, I now have Application ID and Application Secret in my source content node. The feeds import seems to be working as expected also.

gillarf’s picture

Yes I agree, I can't see those fields either. I can see the Facebook Fetcher though, but no config fields on the import page.

RedEight’s picture

Issue summary: View changes

Artofeclipse, did you ever commit that change? I just pulled the latest code from drupal.org and I don't see this fix at all.

RedEight’s picture

Status: Needs review » Needs work
FileSize
9.93 KB

I've downloaded the zip file from #1181858-15: 400 Error: Authentication?. While it seems like this might work, I believe a rewrite is in order. We should add Application ID and Application Secret fields to the fetcher's settings form and set the import form to default to those two values.

I've attached a patch made from abdul.muiz.meer's module posted in comment #15. Artofeclipse said he was going to rewrite and commit the fix, but he said that back in July of 2013 and nothing has been done since.

PS: for those of you having issues after dropping in the new code, make sure you clear your cache before trying to enable the new fetcher. It didn't appear until I had cleared cache.

krisrobinson’s picture

I know this is old, but instead of using the new feeds facebook fetcher etc. I believe you can create a facebook app and use the following url structure for the call:

https://graph.facebook.com/{id}/feed?key=value&access_token={app_id}|{app_secret}

mpardala’s picture

@honucreative I've tried to use that kind of URL, from the browser it works perfectly fine, but when I've tried to use it in the feed aggregator configuration, Drupal doesn't recognize it as a correct URL and doesn't save it
Any thoughts on that one? Thanks

ibraaheem’s picture

@mpardala
It is not recognizing it because of the character "|". You have to use the urlencoded version which is %7C

The url them becomes

https://graph.facebook.com/{id}/feed?key=value&access_token={app_id}%7C{app_secret}

ibraaheem’s picture

I had this problem earlier with Rules and this fix worked for it.

wheelercreek’s picture

Not sure about others but this is still an issue for me. I modified the patch in 27 just a bit here to store the values as variables, so the form remembers them.

wheelercreek’s picture

wheelercreek’s picture

I'm not sure if others are still having this issue, but I modfied the patch from 27 just a bit to store the values as variables.

B_man’s picture

Patch file content purged by author's request.

wheelercreek’s picture

Actually this is a better one here. Need to add a way to select fields coming from Facebook graph. This module currently is only bringing in the ID, Message, and created_time - no matter what fields are selected in the Mapping. This patch (36) allows users to specify what fields they want to add in.

wheelercreek’s picture

Erg.. sorry - Here is the patch I meant to upload!!