Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I wrote a sandbox module that creates a feeds importer for oauthconnector: http://drupal.org/sandbox/jlyon/1481562. I was able to use it to build a feed with feeds_jsonpath_parser that imports events from Facebook.
I'm not sure if this makes the most sense as a stand-alone module, or as part of oauthconnector or oauth_feeds (I posted in the oauth_feeds issue queue: #750272: Integrate with OAuth Common and Http Client), but would be happy to help out with integrating with whatever module makes the most sense.
Here's the readme:
Feeds OAuth Connector Fetcher
Fetches data from OAuth services for aggregation in Feeds.
Dependencies:
oauth
oauthconnector
feeds
http_client
Other Recommended Modules
feeds_jsonpath_parser
-----------------------------
INSTALLATION
-----------------------------
Enable the module from Administer -> Modules as usual.
Create a new Feed
Select the OAuth Connector Fetcher
-----------------------------
EXAMPLE USE-CASE
Creating Pages with your Facebook Feed updates
-----------------------------
Modules
oauth
oauth_common
oauth_common_providerui
oauthconnector
feeds
http_client
feeds_jsonpath_parser
Enable all modules
Go to /admin/structure/oauthconnector/list, click Add Provider from Preset, and choose Facebook
Go to https://developers.facebook.com/apps and create a Facebook App
Enter your site's URL in App Domain
Check the Website row and enter your site's URL
Copy App ID and App Secret keys into the OAuth Consumer Key and OAuth Consumer Secret fields
Under OAUTH CONSUMER ADVANCED SETTINGS, add "read_stream" to the end of the Scope field.
This will give us the proper Facebook permissions
Go to /user and click on the Connections tab
Click on the Facebook button and go through the connection process
Create a new Feeds Importer at /admin/structure/feeds/create
Select the OAuth Connector fetcher
Select the Feeds JSONpath parser
Under Mapping, select JSONpath as the source and your target field
Click on the Parser settings, and enter the JSONpath Context and path to each field
For example: Context = $.data.*, Title = path
Go to /import and select your importer
Enter https://graph.facebook.com/me/home as the Endpoint
Select Facebook as the provider and import your nodes
I have found that Facebook's excellent Graph API Explorer (http://developers.facebook.com/tools/explorer)
is the best way to browse their api.
Comment | File | Size | Author |
---|---|---|---|
#5 | oauthconnector_feeds_user_data_demo.tar_.gz | 1.6 KB | jlyon |
Comments
Comment #1
Frans CreditAttribution: Frans commentedIn my vision this is a separate module.
We cannot generalize the feed functionality. This implements a feature for facebook only. The purpose of the connector module is to generalize user accounts and connections to other platforms. What goes over a connection 'should' not be in connector or oauthconnector.
Comment #2
jlyon CreditAttribution: jlyon commentedSounds good. I think it's wise to limit the scope of the project. I'll set it up as a separate (really small) module.
FYI, this does generalize the feed functionality if you use the JSONpath parser. The above recipe is for Facebook, but I have also been able to ingest events from Google Calendar's REST api by changing the selector paths. In the future I would love to figure out some feeds-ish way to map different Drupal fields to POSTed fields to create content on oAuth providers. I think the ability interact seamlessly with these networks by GET and POST would be a major boon for Drupal, and I don't think it would be very difficult to build onto oauthconnector.
Comment #3
Frans CreditAttribution: Frans commentedWe can offcourse make this a submodule that glues feeds and connector fields together.
One of the big issues right now is populating user profiles, but that requires flexible endpoints and flexible mapping of fields. I know that field mapping is well done in feeds, but what about 'tokenized' endpoints. I don't see how we ever can get that stable with feeds, without people getting crazy from configuration and exceptions.
Do you see an solution for this with feeds? Either as seperate or submodule?
Thing is that we need some fields of a profile for example for a username on registration and the external uid for registration. When using one field... Why not use all fields.
Maybe that could be a starter for a glue between feeds and connector?
Comment #4
jlyon CreditAttribution: jlyon commentedHmm, I don't see any reason why this wouldn't work. I'll try playing around with it in a little bit and let you know if I have any success. It shouldn't require any additional code, just a little feeds configuration. To be honest, the current user field mapping in oauthconnector still kind of confuses me.
Comment #5
jlyon CreditAttribution: jlyon commentedThe attached feature creates a new user field, First Name, and creates an importer to map the username, email and first name from facebook to the appropriate user.
Dependencies:
dependencies[] = "features"
dependencies[] = "feeds"
dependencies[] = "feeds_jsonpath_parser"
dependencies[] = "feeds_oauthconnector_fetcher"
dependencies[] = "oauthconnector"
Instructions
Add email to the FB provider's scope. Go to /import, choose the importer and enter https://graph.facebook.com/me as the endpoint. The other settings should be obvious.
Comment #6
Frans CreditAttribution: Frans commented:)
To be honest... I agree.
It is not good enough, but for time reasons it is, what is for now...
I will look into your code this weekend.
Comment #7
Frans CreditAttribution: Frans commentedComment #8
Frans CreditAttribution: Frans commentedLooks good and I see the value of this.
The downside of this approach, when using for profile fields, is that remote fields can be spread over different endpoints. For example the resource on FB that holds the image is another one then the resource that holds the first name.
You then needs two feeds for one provider, each responsible for some fields. Not too bad, but you need at least one feed for every provider. That is a lot of configuration on a place where I don't expect to do that.
Besides that, endpoints can have tokenized URI:s. With FB you have /me and /me/likes but they are also /[UID]/statuses. I did not solve that with the Fields approach yet, because it was not needed (yet). But it is something to take in account.
Overall, I like the way feeds maps.
But I don't see how we can get this manageable (understandable) for a site admin.
What I really like is the idea of importing flickr streams, FB statuses, tweets etc via Feeds and oauthconnector.
I'll play with it a little more!
Comment #9
Frans CreditAttribution: Frans commentedBTW did you install devel?
admin/structure/oauthconnector/devel
is also fun to explore endpoints with.