|
1 | 1 | <?php |
2 | | -include_once($_SERVER['DOCUMENT_ROOT'].'/APISample/phpsdk.phar'); |
3 | | - |
4 | | - |
5 | | -include_once('config.php'); |
| 2 | +//include_once($_SERVER['DOCUMENT_ROOT'].'/ms_sdk/APISample/phpsdk.phar'); // Use PHAR Archive |
| 3 | +include_once($_SERVER['DOCUMENT_ROOT'].'/ms_sdk/src/MemberSuite.php');// Use the SRC Directory |
6 | 4 |
|
7 | | -$api =newMemberSuite(); |
| 5 | +include_once('config.php'); |
8 | 6 |
|
| 7 | +$api =newMemberSuite(); |
9 | 8 |
|
10 | | -/* |
11 | | - This sample is going to login to the association and create a record with a name, |
12 | | - email, and birthday that you specify. Once saved, the system will display the ID |
13 | | - of the individual created, the age (which MemberSuite calculates), and will automatically |
14 | | - launch the 360 view of that record in the web browser |
15 | | -*/ |
| 9 | +/* |
| 10 | +This sample is going to login to the association and create a record with a name, |
| 11 | +email, and birthday that you specify. Once saved, the system will display the ID |
| 12 | +of the individual created, the age (which MemberSuite calculates), and will automatically |
| 13 | +launch the 360 view of that record in the web browser |
| 14 | +*/ |
16 | 15 |
|
17 | | -// First, we need to prepare the proxy with the proper security settings. |
18 | | -// This allows the proxy to generate the appropriate security header. For more information |
19 | | -// on how to get these settings, see http://api.docs.membersuite.com in the Getting Started section |
20 | | - |
21 | | - |
22 | | -$api->accesskeyId = Userconfig::read('AccessKeyId'); |
23 | | - |
24 | | -$api->associationId = Userconfig::read('AssociationId'); |
25 | | - |
26 | | -$api->secretaccessId = Userconfig::read('SecretAccessKey'); |
27 | | - |
28 | | -// run a WhoAmI to establish a session |
| 16 | +// First, we need to prepare the proxy with the proper security settings. |
| 17 | +// This allows the proxy to generate the appropriate security header. For more information |
| 18 | +// on how to get these settings, see http://api.docs.membersuite.com in the Getting Started section |
| 19 | + |
| 20 | +$api->accesskeyId = Userconfig::read('AccessKeyId'); |
| 21 | +$api->associationId = Userconfig::read('AssociationId'); |
| 22 | +$api->secretaccessId = Userconfig::read('SecretAccessKey'); |
29 | 23 |
|
30 | | -$response =$api->WhoAmI(); |
| 24 | +// run a WhoAmI to establish a session |
| 25 | +$response =$api->WhoAmI(); |
31 | 26 |
|
32 | | -if($response->aSuccess=='false') |
| 27 | +if($response->aSuccess=='false') |
33 | 28 | { |
34 | 29 | echo' Unable to login <br>'.$response->aErrors->bConciergeError->bMessage; |
35 | 30 | die; |
36 | 31 | } |
37 | 32 |
|
38 | | -// now, we want to create a new individual |
39 | | -// First, we need to get a description of the individual |
40 | | -// The description will tell the client SDK how to "build" the object; in other words, what the fields are |
41 | | -// and what the default values are. So if you set a default value for LastName to 'Smith', the Describe |
42 | | -// operation will have that in the metadata. When you construct the object, it will then have the last name |
43 | | -// defaulted to 'Smith' |
| 33 | +// now, we want to create a new individual |
| 34 | +// First, we need to get a description of the individual |
| 35 | +// The description will tell the client SDK how to "build" the object; in other words, what the fields are |
| 36 | +// and what the default values are. So if you set a default value for LastName to 'Smith', the Describe |
| 37 | +// operation will have that in the metadata. When you construct the object, it will then have the last name |
| 38 | +// defaulted to 'Smith' |
44 | 39 |
|
45 | | - |
46 | | -$ObjectResponse =$api->DescribeObject($objectType ='Individual'); |
47 | | - |
48 | | -$meta =$ObjectResponse->aResultValue; |
49 | | - |
50 | | -// now, create our MemberSuiteObject |
51 | | -$metadata =newMembersuiteobjects(); |
52 | | - |
53 | | - |
54 | | -$mso =$metadata->FromClassMetadata($meta); |
55 | | - |
56 | | - |
57 | | -/* it's always easier to use the typed MemberSuiteObject |
58 | | -
|
59 | | - * You could just instantiate this directly by saying: |
60 | | - * |
61 | | - * $person = new msIndividual(); |
62 | | - * |
63 | | - * This would work - but without the class metadata, the object would not respect any of the defaults |
64 | | - * that are set up. It would be a totally blank object.*/ |
65 | | - |
66 | | -$person =newConvertTomsIndividual($mso); |
67 | | - |
68 | | -// Now Assign the value that you want to save |
69 | | - |
70 | | -$person->FirstName ="Jitendra"; |
71 | | - |
72 | | -$person->LastName ="Kumar shukla"; |
73 | | - |
74 | | -$person->EmailAddress ="apitest@membersuite.com"; |
75 | | - |
76 | | -$person->DateOfBirth ="10/5/1989"; |
77 | | - |
78 | | -// Save Data Now |
79 | | -$getsaveResult =$api->Save($person); |
| 40 | +$ObjectResponse =$api->DescribeObject($objectType ='Individual'); |
80 | 41 |
|
81 | | -if($getsaveResult->aSuccess=='false') |
82 | | - { |
83 | | -echo"Unable to save".$getsaveResult->aErrors->bConciergeError->bMessage; |
84 | | - die; |
85 | | - } |
| 42 | +$meta =$ObjectResponse->aResultValue; |
86 | 43 |
|
87 | | -$newpersondetail =newConvertTomsIndividual($getsaveResult->aResultValue); |
88 | | - |
89 | | -echo'Individual saved successfully .<br>'; |
90 | | -echo' LocalId'.$newpersondetail->LocalID.'<br> Name'.$newpersondetail->Name.' <br> Age'.$newpersondetail->Age; |
| 44 | +// now, create our MemberSuiteObject |
| 45 | +$mso =$api->FromClassMetadata($meta); |
91 | 46 |
|
| 47 | +/* it's always easier to use the typed MemberSuiteObject |
| 48 | + * You could just instantiate this directly by saying: |
| 49 | + * |
| 50 | + * $person = new msIndividual(); |
| 51 | + * |
| 52 | + * This would work - but without the class metadata, the object would not respect any of the defaults |
| 53 | + * that are set up. It would be a totally blank object.*/ |
92 | 54 |
|
| 55 | +$person =newmsIndividual($mso); |
93 | 56 |
|
| 57 | +// Now Assign the data that you want to save |
| 58 | +$person->FirstName ="Jitendra"; |
| 59 | +$person->LastName ="Kumar shukla"; |
| 60 | +$person->EmailAddress ="apitest@membersuite.com"; |
| 61 | +$person->DateOfBirth ="10/5/1989"; |
| 62 | +$person->FavoriteColors__c =array('Red','Blue','NONE'); |
| 63 | + |
| 64 | +$address =newAddress(); |
| 65 | +$address->Line1 ='123 Fake St.'; |
| 66 | +$address->Line2 =''; |
| 67 | +$address->City ='Atlanta'; |
| 68 | +$address->State ='GA'; |
| 69 | +$address->PostalCode ='23456'; |
| 70 | +$address->Country ='US'; |
| 71 | + |
| 72 | +$person->Home_Address =$address; |
| 73 | + |
| 74 | +// Save Data Now |
| 75 | +$getsaveResult =$api->Save($person); |
| 76 | +if($getsaveResult->aSuccess=='false') |
| 77 | + { |
| 78 | +echo"Unable to save".$getsaveResult->aErrors->bConciergeError->bMessage.'<br>'; |
| 79 | + die; |
| 80 | + } |
| 81 | + |
| 82 | +$newpersondetail =newmsIndividual($getsaveResult->aResultValue); |
| 83 | + |
| 84 | +echo'Individual saved successfully.<br>'; |
| 85 | +echo' LocalId:'.$newpersondetail->LocalID.'<br> Name:'.$newpersondetail->Name.' <br> Age:'.$newpersondetail->Age.'<br>'; |
| 86 | + |
| 87 | +echo'Now run an update to it.<br>'; |
| 88 | +$newpersondetail->DateOfBirth ="10/15/1989"; |
| 89 | +$newpersondetail->FavoriteColors__c =array('Red','Green'); |
| 90 | + |
| 91 | +// Need to clear this out as it is currently improperly formatted |
| 92 | +$newpersondetail->Addresses =''; |
| 93 | + |
| 94 | +$address =newAddress(); |
| 95 | +$address->Line1 ='222 Fake St.'; |
| 96 | +$address->Line2 =''; |
| 97 | +$address->City ='Atlanta'; |
| 98 | +$address->State ='GA'; |
| 99 | +$address->PostalCode ='90909'; |
| 100 | +$address->Country ='US'; |
| 101 | + |
| 102 | +$newpersondetail->Home_Address =$address; |
| 103 | + |
| 104 | + |
| 105 | +// Save Data Now |
| 106 | +$getsaveResult =$api->Save($newpersondetail); |
94 | 107 |
|
| 108 | +if($getsaveResult->aSuccess=='false') |
| 109 | + { |
| 110 | +echo"Unable to save".$getsaveResult->aErrors->bConciergeError->bMessage.'<br>'; |
| 111 | + die; |
| 112 | + } |
| 113 | + |
| 114 | +echo'Individual updated successfully.<br>'; |
| 115 | +echo' LocalId:'.$newpersondetail->LocalID.'<br> Name:'.$newpersondetail->Name.' <br> Age:'.$newpersondetail->Age.'<br>'; |
95 | 116 | ?> |