CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Google Summer of Code »
  • GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
Pages: 1 ... 4 5 [6] 7 8

Author Topic: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation  (Read 9573 times)

Anudit Verma

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 3
  • Budding author of a concise tech blog.
  • CiviCRM version: 4.7
  • CMS version: Drupal 8 , WordPress 4.4.2
  • MySQL version: 5.6.17
  • PHP version: 5.5.9
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 19, 2015, 08:49:21 pm
Updates:

In today's meeting with Joe McLaughlin, I shared the draft for project plans, we discussed some of the points from it.

Eileen- Actually the github repo is the custom extension including the custom People API along with get entity, I think these are the things you are already familiar with. The AEP which I had developed earlier contains the OSDI spec including "_links" and under that it has link for People's resource which is saved in the osdi.php file. This file was saved/replaced against rest.php which is present in "sites/all/modules/civicrm/extern" directory on the gsoc-server. So I was trying to get the links working on this file and now I would push this file on the github repo as well in a separate directory.

Also from the OSDI specification you could see about links here http://opensupporter.github.io/osdi-docs/aep.html#links
So there is nothing much about modifying the REST link (ie. in this case the complete URL to retrieve the People's resource in OSDI format) into simple URL (not exactly but something like : "/sites/api/v3/people") to GET People's resource on the HAL-browser via AEP link buttons, but it has some guidelines for adding links and concise description on working of embedding a resource.
-for the love of code and always learning

Anudit Verma

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 19, 2015, 09:51:23 pm
Annudit  -

Re git -I think you need to push your hacks to the osdi & rest files to github as a second git repo. It doesn't really reflect a true repo (i.e it's probably not the final location for the work you are doing) but it will make it visible.

Problem statment
I think this is your problem:
When I click on the link from the AEP page I see the link to people as

http://camus.fuzion.co.nz/hal-browser/browser.html#http://camus.fuzion.co.nz/hal-browser/browser.html#/sites/all/modules/civicrm/extern/osdi.php?entity=People&action=get

instead of
http://camus.fuzion.co.nz/hal-browser/browser.html#http://camus.fuzion.co.nz/sites/all/modules/civicrm/extern/osdi.php?entity=People&action=get

or
http://camus.fuzion.co.nz/hal-browser/browser.html#/sites/all/modules/civicrm/extern/osdi.php?entity=People&action=get

Other examples

On the opensupporter example I see
http://api.opensupporter.org/hb2/browser.html#http://api.opensupporter.org/api/v1/people


Looking at the HAL github code they return a format for links like
{
    "_links": {
        "self": { "href": "/orders" },
        "next": { "href": "/orders?page=2" }
    }
}

So, there are variations in the above 2 as to whether the _links section is returning relative or non-relative & the presence of question marks in the url. What variations have you tried returning from your AEP code?

If you can't hit a variation that works it might be time to reverse engineer the transformation going on in the HAL browser in this bit of code.

https://github.com/mikekelly/hal-browser/blob/master/browser.html#L65
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Anudit Verma

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 3
  • Budding author of a concise tech blog.
  • CiviCRM version: 4.7
  • CMS version: Drupal 8 , WordPress 4.4.2
  • MySQL version: 5.6.17
  • PHP version: 5.5.9
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 21, 2015, 01:37:39 am
Updates:

I have pushed the AEP file (osdi.php) in a separate repository on github, you can view it here https://github.com/anuditverma/CiviCRM-OSDI-Files

Eileen- I tried different variations of URL (with/without API keys, including JSON code, upto entity) none of them worked, may be because of the presence of question marks.

Then I worked on AEP for another variation which might be a potential solution for this, under "_links" then for "self" I have provided the URL for people's record titled "The collection of people" and following the HAL format which would generate the next link (as in here for viewing the individual person's record) I would be embedding the array of People's record, so it would show the individual record when an contact_id is passed into the array. It is not the actual code but bit of a potential way to generate the individual record, So could you look into the code and comment if I can possibly able to call that return function in this way. Here is the link of the file pushed on github https://github.com/anuditverma/CiviCRM-OSDI-Files/blob/master/sites/all/modules/civicrm/extern/osdi2.php

Thank you.
-for the love of code and always learning

Anudit Verma

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 21, 2015, 03:53:51 am
So, you have replaced the php file you previously had in osdi.php with a flat file in order to try out variants of the links?

I stuck up a file next to your files on camus

http://camus.fuzion.co.nz/hal-browser/browser.html#/sites/all/modules/civicrm/extern/osdie.php?entity=People&action=get

& it seems to be moving to relative urls ok - but of course - there is nothing to retrieve because the file you had earlier to return results is not there at the moment from what I can tell
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Anudit Verma

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 3
  • Budding author of a concise tech blog.
  • CiviCRM version: 4.7
  • CMS version: Drupal 8 , WordPress 4.4.2
  • MySQL version: 5.6.17
  • PHP version: 5.5.9
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 21, 2015, 10:16:00 am
Yes I did some replacements, I had previously worked on another temporary file called osdi2.php in which I tried my URL variations but then since we have decided to develop the final AEP into the osdi.php so I starting working on this file.

Relative URLs do work in HAL-browser, but the return function with OSDI formatting exists in the Get.php entity file which is present in the custom extension directory exactly at “/sites/default/ext/org.civicrm.osdi/api/v3/People” on the camus server. So what I believe ideally it should work as osdie.php contains only the AEP and caller URL to retrieve the People's data.

So as per my observation on working of OSDI sample page of people (http://api.opensupporter.org/hb2/browser.html#http://api.opensupporter.org/api/v1/people) when its GET link is clicked it returns a list of array of individual person, each having incrementing whole number values passed as an argument. This is what I thought of implementing on the new github repo so that I can have a possible way of retrieving the desired result.
-for the love of code and always learning

Anudit Verma

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 21, 2015, 02:23:51 pm
OK - so is the plan that the osdi.php will have php code in it, much like rest.php that takes the parameters out of the url & calls your api appropriately (or returns AEP data if no entity is specified) & ensures the results are formatted correctly?

Or were you planning on redirecting the browser to a different url?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Anudit Verma

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 3
  • Budding author of a concise tech blog.
  • CiviCRM version: 4.7
  • CMS version: Drupal 8 , WordPress 4.4.2
  • MySQL version: 5.6.17
  • PHP version: 5.5.9
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 21, 2015, 08:01:26 pm
updates:

In today's meeting with Joe McLaughlin and Eileen we discussed about the AEP code present in osdi.php file, so I have decided to make a general formatting function and caller function in php. This formatting function would modify the CiviCRM fields into OSDI format, it would map all the possible fields so that I wouldn't have to develop the entity file having the formatting function for each API. Also a general caller function would be developed that would accept the action and entity as parameters  and returns the requested data through the REST URL after the proper formatting has been done by formatting function.

Eileen- I would embed the JSON into osdi.php having the php code as it was having earlier like that of rest.php and then add these functions.

Thanks
-for the love of code and always learning

Anudit Verma

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 21, 2015, 08:25:10 pm
Great - looking forward to seeing what you get done today. & yes, the osdi.php file would return the json you mention, as appropriate
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Anudit Verma

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 3
  • Budding author of a concise tech blog.
  • CiviCRM version: 4.7
  • CMS version: Drupal 8 , WordPress 4.4.2
  • MySQL version: 5.6.17
  • PHP version: 5.5.9
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 23, 2015, 07:20:58 am
Updates:

I have modified the osdi.php file containing the AEP and added php code which now produces the response code on the HAL-browser in JSON representation, modified code can be viewed here https://github.com/anuditverma/CiviCRM-OSDI-Files/blob/master/sites/all/modules/civicrm/extern/osdi.php

Also by trying some more variations of URLs, it is working fine when I am using rest.php (original REST URL) along with API & site keys. I have added this People's resource link in the AEP which is now able to show up the data when GET link button is clicked. This can be viewed on the HAL-browser here http://camus.fuzion.co.nz/hal-browser/browser.html#/sites/all/modules/civicrm/extern/osdi.php

Eileen- It will be great if I am able to develop those functions I proposed in the last update, so the idea is to get the Action and entity from the REST URL, a wrapper would include these function having an outer function to identify those objects present in the URL and pass them to caller function and before ending up to show the data it would be passed by a formatting function that would apply the OSDI based format. So I just want to know from where actually the REST URL will be called, I don't think that I should add any function to the AEP as it a structure for having collection of links of various resources' end points. Prior to this I think if I can create a php code for fetching those requested REST URL but I need to where these REST URL will finally end up for API communication, I just thought of an another view if it will be possible to create another simple extension that would communicate with CiviCRM's API (like we see on API explorer) just for the purpose of getting the REST URL passed to the function. So what are your thoughts on this ? Meanwhile I'll try to find the best way possible to make this work.

Thanks.
-for the love of code and always learning

Anudit Verma

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 23, 2015, 02:11:49 pm
I think it makes sense to call the api from the osdi.php as that is the access point. You can copy rest.php for code to help get civi initialized from that file. OSDI.php is kindof the osdi equivalent to rest.php. If you instantiate CiviCRM  in there you will be able to call your api calls using php in there.


Then the actual api can sit in your extension & osdi.php can provide the wrapper
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Anudit Verma

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 3
  • Budding author of a concise tech blog.
  • CiviCRM version: 4.7
  • CMS version: Drupal 8 , WordPress 4.4.2
  • MySQL version: 5.6.17
  • PHP version: 5.5.9
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 27, 2015, 01:48:23 am
Updates:

Over this weekend I developed the AEP more, I have added more resource links and another page for people's resource. Now a index.php file exists within the People API directory of the custom extension which would include the list of individual person's resource.

AEP can be viewed here http://camus.fuzion.co.nz/hal-browser/browser.html#/sites/all/modules/civicrm/extern/osdi.php

Also I am using a PHP library for HAL, by which I am able to get the required structure for embedded resource that would include the individual records fetched from CiviCRM's database via REST URL.
This Hal PHP library is placed and installed at “/sites/all/libraries” which is a directory for downloaded and custom libraries.

It can be viewed on github here https://github.com/blongden/hal

Next target:
Currently I am working on the people's resource page with the help of this library to get the person's records in proper format as seen on OSDI's sample page.
-for the love of code and always learning

Anudit Verma

joemcl

  • I post occasionally
  • **
  • Posts: 72
  • Karma: 1
    • Citizen Action of New York
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7.34
  • MySQL version: 5.6
  • PHP version: Unsure
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 27, 2015, 08:37:53 pm
Anudit, thanks, great to see progress.

Anudit Verma

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 3
  • Budding author of a concise tech blog.
  • CiviCRM version: 4.7
  • CMS version: Drupal 8 , WordPress 4.4.2
  • MySQL version: 5.6.17
  • PHP version: 5.5.9
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 28, 2015, 07:34:17 am
Updates:

In today's meeting with Joe McLaughlin and Eileen I presented the AEP having people's resource list in the required format as it is present on OSDI's sample page through sharing my screen on Hangout. I was getting a 403 error with URLs when I uploaded the files on the camus (gsoc-server) to which Eileen figured out that I must change the name of my custom extension directory from org.civicrm.osdi to osdi (any name for now without having dots in the naming convention which was causing the problem). The AEP link is fixed and works fine now on the camus server as well, it can be seen here
http://camus.fuzion.co.nz/hal-browser/browser.html#/sites/all/modules/civicrm/extern/osdi.php

Also I have pushed the code on github which produces only the required structure of list that will include the CiviCRM's people data. The code can be viewed here https://github.com/anuditverma/OSDI-Implementation/blob/master/api/v3/People/index.php

Next target:
I will now work on including the CiviCRM's people resources to be presented against the corresponding fields on the people's endpoint on the AEP which will be retrieved with the help of REST URL.

Thanks.
-for the love of code and always learning

Anudit Verma

Anudit Verma

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 3
  • Budding author of a concise tech blog.
  • CiviCRM version: 4.7
  • CMS version: Drupal 8 , WordPress 4.4.2
  • MySQL version: 5.6.17
  • PHP version: 5.5.9
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 29, 2015, 11:59:27 am
Updates:

In today's meeting on IRC with Joe McLaughlin and Eileen I discussed about setting options to provide limit for returning maximum number of records also since I had change the name of my custom extension on the camus server because of which the REST URL for retrieving the people's record was not working, so we discussed on fixing that as well. Also I had an email conversation with Jason Rosenbaum from Action Network, I discussed with him about PHP library I was working with so he advised me to go ahead with it as they also use ruby/rails library for achieving the same result as on OSDI's API sample page.

Today I worked on my previously specified target, now I am able to generate the People endpoint page with all the individual person's data presented at respective OSDI specified fields.
I have updated the code on my repo here https://github.com/anuditverma/OSDI-Implementation/blob/master/api/v3/People/index.php

Eileen-  The code is working fine on my local machine as I have made no changes till now as I did on the camus by changing the name of the custom extension. So I backed up my API files present in the extension, uninstalled & deleted it and created a new one with

Code: [Select]
civix generate:module osdi –license=AGPL-3.0
but it throws an error
Code: [Select]
Malformed package name
this is because it follows fully qualified extension names as per the documentation.

Also I tried replacing instances of org.civicrm.osdi to osdi but some of the php files contains functions which had their names based on fully qualified extension name.

These changes are required for proper functioning of the extension and also because I run my development environment on Apache whereas on the camus it runs on nginx so certainly it won't be working the same. So if you could make some changes in the server configuration of camus so that I need not to modify (for eg custom extension's name by removing dots in between) my custom extension in future as well or from now onwards if I can follow some conventions in the development process primarily for nginx.

Meanwhile I am also trying if I can achieve the same results on the camus as I am getting locally.

Thank you.
« Last Edit: July 29, 2015, 12:13:34 pm by Anudit Verma »
-for the love of code and always learning

Anudit Verma

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation
July 29, 2015, 07:48:20 pm
Talked with Eileen a little on IRC about the civix issue. Some notes:

 1. Extensions must declare a long/dotted name in "info.xml" like "org.civicrm.osdi".

 2. The long name is used in various places (in info.xml, in the folder name, when registering JS/CSS files, in the public extension directory, etc). Sometimes it's required, sometimes it's just a convention/recommendation.

 3. It's a convention that the directory-name matches the long/dotted name, and most of the docs+tools will use this convention, but the core system doesn't really care. It's legal to rename the folder to something else -- e.g "civix generate:module org.civicrm.osdi ; mv org.civicrm.osdi osdi".

Out of idle curiosity... what's wrong with doing "civix generate:module org.civicrm.osdi" and using the default/convention?

Pages: 1 ... 4 5 [6] 7 8
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Google Summer of Code »
  • GSoC 2015 : New API : Open Supporter Data Interface (OSDI) Implementation

This forum was archived on 2017-11-26.