More in this section

Forums / Developing with Sitefinity / Web Service with Php

Web Service with Php

4 posts, 0 answered
  1. Chris Holmes
    Chris Holmes avatar
    3 posts
    27 Aug 2009
    06 May 2015
    Link to this post

    I am looking for help with linking the sitefinity pre-built web services to a website. The website is local,
    and run in php code. Below are some notes I've taken, in order to post a thread in order for someone to
    possibly help me.

    Specs, or whatever. What I want to be done:
    I want to use the user.svc web service.
    I want to crud users.
    I want to use the userprofiletypesservice.svc web service.
    I want to get profile types based on user id or whatever.
    I want this to happen in php.

    What I've tried:
    I went here (among other places).

    This told me to use this url to get authentication:
    I run this in a browser, nothing happens.

    I do this code in php:
    $test = curl_init("http://localhost:60876/Sitefinity/Services/Security/Users.svc/authenticate");
    $fp = fopen("test.txt", "w");

    curl_setopt($test, CURLOPT_FILE, $fp);
    curl_setopt($test, CURLOPT_HEADER, 0);

    I get this response:
    "IIS 8.0 Detailed Error - 401.0 - Unauthorized"
    as well as other stuff.

    Conclusion questions:

    What am I doing wrong? 
    How do I get the cookie with authentication stuff into some php variable?
    Do I need to use visual studio to do this, and then link up to a web service that I build myself, that
    will do all the validation, and I can then just link the php into that web service? That is too

    So, there is my synopsis. If anyone has some clarity to throw at me, i'd appreciate it.


    I also went here:

    I downloaded this, opened the .sln with VS2013, built it, and ran it. It runs at first, but the program doesn't really work. I tried claims authentication, with url: http://localhost:60876/sitefinity/services/security/users.svc/authenticate/

    I typed in my username and pass.

    I hit login. Login goes unclickable, I can click list data or logout. If I hit list data, i get an error message saying stuff, but I can click continue, and the program still runs. If I hit logout, the program does nothing. If I hit create new product, things happen. BUT, this is the beginning of response data: 

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ""> 
    <html xmlns=""> 
    <title>IIS 8.0 Detailed Error - 401.0 - Unauthorized</title> 
    <style type="text/css"> 

     There's that Unauthorized again!!!!

    What is wrong?

  2. Grisha 'Greg' Karanikolov
    Grisha 'Greg' Karanikolov avatar
    156 posts
    14 Jun 2017
    07 May 2015
    Link to this post
    Hello Chris,

    You might want to check out this post for a fully-working sample for authenticating through RESTful web services. Hopefully this will help with your task!

    Grisha 'Greg' Karanikolov
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
  3. Tim
    Tim avatar
    258 posts
    22 Jun 2011
    07 May 2015 in reply to Chris Holmes
    Link to this post


    I've done a bit of work with the services. Here is a PHP version of the authentication mechanism. Also, I've done quite a bit of tinkering with the services themselves. Here's a C# example of working with them. (The relevant code would just need ported to PHP.)

    Hopefully the answers to your questions are in there. :)

  4. Jeremy
    Jeremy avatar
    10 posts
    13 May 2015
    14 May 2015
    Link to this post

    Hi all, 

     I've done a bit of digging, and I still haven't wrapped my head around this yet. I went to this page: <> and took a look at the RESTfulClient project. TBH, I still don't understand it, and perhaps that is my downfall.

    Anyways, I also went to this page: <>. Tim describes his problem with connecting to the sitefinity web services, using java. This is sort of where I am at.

    I have a sitefininty website project that is opened in Visual Studio 2013. I hit start without debugging, and the website opens in my browser. I see the page, and I can login with username/password. 

    Then, I have this php website. It uses curl to call the users.svc/authenticate web service. I pass in an array of strings, which give the credentials. {$provider = array("MembershipProvider" => "","Password" => "password","Persistent" => true,"UserName" => "username);}.

    I call curl_exec, to run the call to the web service, and I put the output into a local text file.

    When I look at this text file, it has a 401 error.

    Now, am I doing this wrong? All I'm doing is calling the web service. Do I need to be doing this from within my sitefinity project, and then passing the token out to the php site? The php site is NOT within the sitefinity project folder. Am I having permission issues? 

     The only two possibilities that I can think of is that my syntax is wrong with passing the parameters to the web service, or that I'm going about this the wrong way, and as a developer, I'm not actually supposed to be calling the web service directly from a sitefinity site. This confuses me, because on the following page, it says that the web services are "exposed and available for 3rd party applications and devices." <>


    PS - I started this thread under a different account. This is my actual name...

4 posts, 0 answered