Customer Portal

Get Involved. Join the Conversation.

Topic

    Janusz Jasinski
    Is there A ConnectPHP API Dummies Guide?Answered
    Topic posted January 19, 2017 by Janusz JasinskiSilver Crown: 22,500+ Points, last edited January 19, 2017 
    241 Views, 10 Comments
    Title:
    Is there A ConnectPHP API Dummies Guide?
    Content:

    Hi all,

    I think this may be worth a discussion. I'm au fait with PHP but some of my team are not, but they understand the usual suspects of HTML, CSS and JavaScript. As such, using the ConnectPHP API isn't the most intuitive of things.

    As the title suggests, is there some sort of dummy guide we can reference to help us along our way? Maybe even open up a new forum specifically for questions around ConnectPHP?

    I'm just thinking simple things about how to extract information (given a user session or static parameters), update it, delete it etc

    If someone came to RightNow with no PHP experience or limited experience, where do you suggest they start?

    Subject edited by Danette Beal for clarity

    Best Comment

    Rajan Davis

    Hi Janusz,

    To be very frank, I think what you are asking for is a lot bigger than just the ConnectPHP API. The API itself can be used in multiple scenarios:

    1. As a Custom Process Model (CPM) script -  I am not 100% sure, but I think these are custom scripts that are hosted through the console that are accessible through a specific URL. I haven't really used it in this way, but I am aware of it. You can find more information here
    2. In Analytics Reports - the reports have the ability to utilize the ConnectPHP API and regular PHP scripts. This is a really cool way to do some data manipulations, but I find that this is incredibly difficult to debug as script errors will fail silently (or you have to specify to a log which I am not sure how to access). I prefer to use the custom scripts with vanilla PHP only or, if I have a complex report, use the ConnectPHP API to use report results and then run them in another report so I can run multiple reports in one report.
    3. In Custom Controllers - this is where I have used the ConnectPHP API the most. I would venture to say that the majority of how the customer portal works (at least for CP 2.0) is through AJAX with controller endpoints. I have used controllers to generate JSON, perform complex but predictable automations, as well as create HTML templates that can be accessed via AJAX.
    4. In Custom Models - this is basically a nice way to create reusable code across the customer portal as it relates to business objects. I will often tie in very complex, object specific logic into a custom model so that it can be called from a custom controller when I am passing information in via AJAX.

    If it is preferable to you, you can send me a message and we discuss this a bit further outside of the forums. Again, to be very frank, the way the customer portal works was very cutting edge in it's inception but, in my opinion, is very much a legacy application. How things apply in terms of MVC is arguably outdated and can be a little convoluted.

    I would strongly suggest reading through the code examples in the ConnectPHP API specific to an object. I would pick one and try to work through creating an Answer using the example code; this was how I familiarized myself with this information.

    For the most part, you do not need to write custom code but rather utilize existing functionality; however, it took me several months to "get" how the customer portal internals work. 

    Additionally, I would read through the source code; there is a ton of information in there and it should give you more insight on how sessions are created and destroyed as well as how the customer portal "works". I would use the Fiddler chrome extension and trace which controller methods are being called via AJAX and then read the source code.

    If you are on CP3, you will have a hard time reading the internal libraries as they are restricted from WebDav access, but I have a way around that. The only issue is that you cannot make use of these libraries in custom code, there are restrictions in place that limit you.

    Kind Regards,

    Rajan

    Comment

     

    • Barrilito van Dijk

      Hi Janusz,

      I think in general you are saying that you have people with some minor php knowledge that are missing things.

      What are you missing here in the documentation?

      http://documentation.custhelp.com/euf/assets/devdocs/november2016/Connect_PHP/Default.htm

      I think it is well documented, but that is perhaps depending on what you expect.

      Please understand that using rightnow / osc requires some skills. If you say if someone starts with no or minor php knowledge, that is no problem, but then you should focus first on some php training instead of debating about the correctness and availablility on dummy guides. But be aware that it is not "just" php or connect, it is also customer portal coding, etc. It is a combination of so many things. Perhaps it should not be an assumption that just anyone can do this with one day...

      Regarding starting a forum... you are on it!  wink  And the specific on should be this one.

      Regards.

    • Danette Beal

      Hi Janusz,

      Although the documentation can be dry and not as to the point as maybe a Cliff Notes version, I do believe it is thorough. Barrilito is also correct in the Connect Data Services forum being the forum you would want your team to post questions to. I'm excited to see you answering questions on this forum as well!! Something to keep a look out for is our upcoming Modern Service Experience event April 25-27th. This event features Developer content this year and we're excited to get the Developer Community engaged and involved as you all are really the pioneers for the product moving into the future.

      As soon as more details are available we'll post them on the Community!

      Regards,

      Danette, Community Manager 

    • Janusz Jasinski

      I mean to have it as an extra forum board on this page http://communities.rightnow.com/groups/bef552360b/summary as I feel its a huge subject worthy of its own status, but understand what has been said.

      My expectations come from working on other systems where they've gone through a lot more examples and almost took you from knowing nothing to knowing a lot.

      I certainly don't think it's structured well - I'm sure the content is good but it's not obvious as to the flow of content

    • Danette Beal

      Thanks for your honest feedback Janusz! We really do appreciate it.

      We are always evaluating when and if we should create another more specific boards and I will make a note of your request. One of our evaluation points in determining the growth of the Community is how many Members we have that are higher contribution members. As you've seen, There are a handful of Members whom are the first to roll up their sleeves and help out whenever needed. It sounds like you are in the midst of growing a team and I would love to see you mentor them into giving back to the Community once they grow their knowledge or even begin contributing with any existing knowledge they have. I always get excited when I see you answer questions because of the potential you have in being one of our higher contributors. If you have any questions around this, please feel free to reach out! And keep the feedback coming!

      Regards,

      Danette, Community Manager

    • Rajan Davis

      Hi Janusz,

      To be very frank, I think what you are asking for is a lot bigger than just the ConnectPHP API. The API itself can be used in multiple scenarios:

      1. As a Custom Process Model (CPM) script -  I am not 100% sure, but I think these are custom scripts that are hosted through the console that are accessible through a specific URL. I haven't really used it in this way, but I am aware of it. You can find more information here
      2. In Analytics Reports - the reports have the ability to utilize the ConnectPHP API and regular PHP scripts. This is a really cool way to do some data manipulations, but I find that this is incredibly difficult to debug as script errors will fail silently (or you have to specify to a log which I am not sure how to access). I prefer to use the custom scripts with vanilla PHP only or, if I have a complex report, use the ConnectPHP API to use report results and then run them in another report so I can run multiple reports in one report.
      3. In Custom Controllers - this is where I have used the ConnectPHP API the most. I would venture to say that the majority of how the customer portal works (at least for CP 2.0) is through AJAX with controller endpoints. I have used controllers to generate JSON, perform complex but predictable automations, as well as create HTML templates that can be accessed via AJAX.
      4. In Custom Models - this is basically a nice way to create reusable code across the customer portal as it relates to business objects. I will often tie in very complex, object specific logic into a custom model so that it can be called from a custom controller when I am passing information in via AJAX.

      If it is preferable to you, you can send me a message and we discuss this a bit further outside of the forums. Again, to be very frank, the way the customer portal works was very cutting edge in it's inception but, in my opinion, is very much a legacy application. How things apply in terms of MVC is arguably outdated and can be a little convoluted.

      I would strongly suggest reading through the code examples in the ConnectPHP API specific to an object. I would pick one and try to work through creating an Answer using the example code; this was how I familiarized myself with this information.

      For the most part, you do not need to write custom code but rather utilize existing functionality; however, it took me several months to "get" how the customer portal internals work. 

      Additionally, I would read through the source code; there is a ton of information in there and it should give you more insight on how sessions are created and destroyed as well as how the customer portal "works". I would use the Fiddler chrome extension and trace which controller methods are being called via AJAX and then read the source code.

      If you are on CP3, you will have a hard time reading the internal libraries as they are restricted from WebDav access, but I have a way around that. The only issue is that you cannot make use of these libraries in custom code, there are restrictions in place that limit you.

      Kind Regards,

      Rajan

    • Janusz Jasinski

      Top answer - may well take you up on that offer! I just feel a full library of examples ala jQuery would be useful

    • Dietrik

      I'd advice these people to invest in some proper training, Have a trainer or experienced consultant over for a couple of days to show the basics and guide them through the initial stages.

      This will get them up to speed fast and save them the frustration to try to find out themselves.

    • Barrilito van Dijk

      Hi Janusz,

      Was your question answered with the feedback you got? If so, as there is not so much to add to it I guess, perhaps set a best answer to close of the post. Or perhaps give your own end conclusion to this all and set that as best answer. Thanks.

      Regards

    • Andrew Rowse

      Having IDE based code completion for ConnectPHP can really help with the learning curve. My company has a free tool out there than can generate PHPDocs for a site's ConnectPHP API that has pretty complete coverage. If you use an IDE that supports PHPDocs, such as NetBeans (and I think Eclipse), this can speed things up significantly.

      New version of the toolkit is available here: http://cxdeveloper.binpress.com/product/cxdev-toolbox/3941

      Details on the PHP Stub generator here: http://cxdeveloper.com/article/cxdev-toolbox-php-stub-generator

    • Janusz Jasinski

      That's great - unfortunately we can't run/install executables!