2

My code makes a call to a service called OneID. The code is javascript and it prompts you to authorize the sharing of your email address (stored in the OneID repository) with a site.

OneID Prompt

I need the email address to be returned to the parent page if the user clicks, "OK".

Right now, all I can get it to do is generate a javascript Alert.

Note If you decide to help with this, you'll need to create a OneID account, sorry.

    <script src="https://api.oneid.com/form/form.js" type="text/javascript"></script>';

    echo '<script type="text/javascript">

    OneIdExtern.registerApiReadyFunction(
        function(){
            OneId.getUserAttributes(
                {
                    attr: "email[email]", 
                    authLevel : null, 
                    selectCards : true,
                    forceSelectCards : true
                },
                function(data){ 
                    if (data.attribute_data.email.email) {
                        <<-- somehow send data back to page? -->>
                    }
                }   
            );
        }
    );
    </script>';
000
  • 26,951
  • 10
  • 71
  • 101
Dan
  • 4,197
  • 6
  • 34
  • 52
  • possible duplicate of [Reference: Why does the PHP code in my Javascript not work?](http://stackoverflow.com/questions/13840429/reference-why-does-the-php-code-in-my-javascript-not-work) – Quentin Jun 17 '13 at 11:56
  • don't use a prompt, use a modal with an `` for the address, and a ` – Mike 'Pomax' Kamermans Jun 17 '13 at 11:59
  • Assuming the email address is in the data returned by OneID, you can call your own function with that data and/or make an ajax-call to a specific document on your server and send the email address as data with that request. It depends on what exactly you want to do with that email address. – Sumurai8 Jun 17 '13 at 12:04
  • @Sumurai8 -- yes, I actually need to take the email address and curl it to a site within a php environment. – Dan Jun 17 '13 at 13:53

1 Answers1

0

I suspect your problem is to inform your backend of the email that have just been entered. I see 2 way to do this:

  1. If user have a form to validate as a next step, just prepare a Hidden field and store the email in there. It will be posted when the form will be validated
  2. In real time, you can write a script on your server and call it with the email using Jquery (at the place you put you comment: <<-- somehow send data back to page? -->>). If you need to matchwith server information, put you'll probably need to maintain a session.

On more remark: if not constraints by cross domain issue, you can make your call directy in javascript instead of curling from your backend.

Pr Shadoko
  • 1,649
  • 2
  • 15
  • 16