I create cookies authentication in action login but in another controller or another action, i call it but it just echo user'name and nothing else.
For example:
class LoginController extends Controller
{
public function actionIndex()
{
if (isset($_POST['UserLogin'])) {
$username = $_POST['UserLogin']['email'];
$password = $_POST['UserLogin']['password'];
$dataLogin = Users::model()->findByAttributes(array('email'=>$username, 'password'=>md5($password), 'role'=>1, 'status'=>1));
if($dataLogin == NULL) {
Yii::app()->user->setFlash('login_mess',Yii::t('app','Invalid email or password!'));
$this->redirect($_SERVER['HTTP_REFERER']);
}
else{
Yii::app()->session['Authentication'] = $dataLogin;
$cookies = new CHttpCookie('authentication', $dataLogin);
$cookies->expire = time() + 7*24*60*60;
Yii::app()->request->cookies['authentication'] = $cookies;
$this->redirect('/profile');
}
}
}
public function actionLogout()
{
echo "<pre>";
print_r(Yii::app()->request->cookies['authentication']);die;
echo "</pre>";
Yii::app()->session['Authentication'] = null;
$this->redirect('/');
}
}
In actionLogout i try print that cookies:
CHttpCookie Object
(
[name] => authentication
[value] => Bàn Chân Trần
[domain] =>
[expire] => 0
[path] => /
[secure] =>
[httpOnly] =>
[_e:CComponent:private] =>
[_m:CComponent:private] =>
)
but i expect:
CHttpCookie Object
(
[name] => authentication
[value] => Users Object
(
....
[_new:CActiveRecord:private] =>
[_attributes:CActiveRecord:private] => Array
(
[id] => 4
[name] => Bàn Chân Trần
[email] => hongquan156#gmail.com
[phone_code] => +44
[phone] => 0988888888
[country] => 2
[language] => vi
[password] =>
[role] => 1
[device_token] =>
[active_key] => 9D9T7n1oWlFiRy1EJ3ULDVlBDtw4VQWT
[status] => 1
[token] =>
[payment] => 0
[created] =>
)
[_related:CActiveRecord:private] => Array
(
)
[_c:CActiveRecord:private] =>
[_pk:CActiveRecord:private] => 4
[_alias:CActiveRecord:private] => t
[_errors:CModel:private] => Array
(
)
[_validators:CModel:private] =>
[_scenario:CModel:private] => update
[_e:CComponent:private] =>
[_m:CComponent:private] =>
)
[domain] =>
[expire] => 1345801074
[path] => /
[secure] =>
[httpOnly] =>
[_e:CComponent:private] =>
[_m:CComponent:private] =>
)
How can I reslove this problem... thanks!
Since you're storing an object to cookie, you mus serialize it before storing it to cookie, and unserialize it after retrieving it :
$cookies = new CHttpCookie('authentication', serialize($dataLogin));
print_r(unserialize(Yii::app()->request->cookies['authentication']));die;
Related
This is the response when I call the login method from twinfield API. It given the session id and cluster namespace, but the problem is how to get the value from it.
$customerApiConnector = new \PhpTwinfield\ApiConnectors\CustomerApiConnector($login);
print_r($customerApiConnector);die;
Output:
PhpTwinfield\ApiConnectors\CustomerApiConnector Object
(
[service:protected] => PhpTwinfield\Services\ProcessXmlService Object
(
[trace] => 1
[compression] => 32
[_stream_context] => Resource id #153
[_soap_version] => 1
[sdl] => Resource id #154
[__default_headers] => Array
(
[0] => SoapHeader Object
(
[namespace] => http://www.twinfield.com/
[name] => Header
[data] => Array
(
[SessionID] => f7b4c213-1a01-4c7c-87cb-7de80b1583fe
)
[mustUnderstand] =>
)
)
)
)
This is the other object.
Array
(
[1] => PhpTwinfield\CustomerAddress Object
(
[ID:PhpTwinfield\CustomerAddress:private] => 1
[type:PhpTwinfield\CustomerAddress:private] => invoice
[default:PhpTwinfield\CustomerAddress:private] => true
[name:PhpTwinfield\CustomerAddress:private] => Anand
[contact:PhpTwinfield\CustomerAddress:private] =>
[country:PhpTwinfield\CustomerAddress:private] => IN
[city:PhpTwinfield\CustomerAddress:private] => Indore
[postcode:PhpTwinfield\CustomerAddress:private] => 452001
[telephone:PhpTwinfield\CustomerAddress:private] =>
[fax:PhpTwinfield\CustomerAddress:private] =>
[email:PhpTwinfield\CustomerAddress:private] => anand#comfisoft.com
[field1:PhpTwinfield\CustomerAddress:private] =>
[field2:PhpTwinfield\CustomerAddress:private] => lig
[field4:PhpTwinfield\CustomerAddress:private] =>
[field5:PhpTwinfield\CustomerAddress:private] =>
[field6:PhpTwinfield\CustomerAddress:private] =>
)
)
Try this it will work ;)
function accessProtectedProperty($obj, $prop)
{
$reflection = new \ReflectionClass($obj);
$property = $reflection->getProperty($prop);
$property->setAccessible(true);
return json_decode($property->getValue($obj));
}
I am new to tables/arrays and I can't get this to work.
I am trying to get The data of "EntityId", and it doesn't work if I change "Phone" to "EntityId". I tried much more but I can't figure it out on my own. I hope someone can explain what I am doing wrong or maybe I did't notice something.
Any help would be appreciated.
Script
<?php
require_once 'autoload.php';
$username = '*****************';
$password = '*********';
$authWsdl = 'https://webservices.autotask.net/atservices/1.5/atws.wsdl';
$opts = array('trace' => 1);
$client = new ATWS\Client($authWsdl, $opts);
$zoneInfo = $client->getZoneInfo($username);
$authOpts = array(
'login' => $username,
'password' => $password,
'trace' => 1, // Allows us to debug by getting the XML requests sent
);
$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
$client = new ATWS\Client($wsdl, $authOpts);
// Instantiate a Query object, designed to make complex
// queries simple.
$query = new ATWS\AutotaskObjects\Query('Contact');
$firstnameField = new ATWS\AutotaskObjects\QueryField('ID');
$firstnameField->addExpression('Equals', '30682996');
$query->addField($firstnameField);
// If you want to debug the XML produced by the Query object
// print($query->asXml());
// Print the results of the query
print_r($client->query($query));
$json = ($client->query($query));
$phone = $json->queryResult->EntityResults->Entity->Phone;
echo $phone;
output
ATWS\AutotaskObjects\QueryResponse Object
( [queryResult] => ATWS\AutotaskObjects\ATWSResponse Object
( [EntityResults] => ATWS\AutotaskObjects\ArrayOfEntity Object
( [Entity] => ATWS\AutotaskObjects\Contact Object
( [AccountID] => 236
[Active] => 0
[AdditionalAddressInformation] =>
[AddressLine] => Dorpstraat
[AddressLine1] =>
[AlternatePhone] => 040-4444555566
[City] => Veldhoven
[Country] => Netherlands
[CountryID] => 158
[CreateDate] => 2017-11-18T05:36:46.14
[EMailAddress] => Email#email.nl
[Extension] =>
[ExternalID] =>
[FaxNumber] => 467863453
[FirstName] => Ellis
[LastActivityDate] => 2017-11-18T05:36:46.14
[LastModifiedDate] => 2017-11-18T05:36:46.127
[LastName] => Dodo
[MiddleInitial] =>
[MobilePhone] => 061231235
[Note] =>
[Notification] => 1
[Phone] => 040-4444555566
[RoomNumber] =>
[State] => GH
[Title] =>
[ZipCode] => 5890aa
[Fields] =>
[UserDefinedFields] => ATWS\AutotaskObjects\ArrayOfUserDefinedField Object
( [UserDefinedField] => )
[id] => 30682996
[BulkEmailOptOut] =>
[SurveyOptOut] =>
[FacebookUrl] =>
[TwitterUrl] =>
[LinkedInUrl] =>
[PrimaryContact] => ) )
[EntityResultType] => contact
[EntityReturnInfoResults] => ATWS\AutotaskObjects\ArrayOfEntityReturnInfo Object ( [EntityReturnInfo] => ATWS\AutotaskObjects\EntityReturnInfo Object ( [DatabaseAction] => None [DuplicateStatus] => ATWS\AutotaskObjects\EntityDuplicateStatus Object ( [Found] => [Ignored] => [MatchInfo] => [Fields] => [UserDefinedFields] => ) [EntityId] => 30682996 [Message] => [Fields] => [UserDefinedFields] => ) [Fields] => [UserDefinedFields] => ) [Errors] => ATWS\AutotaskObjects\ArrayOfATWSError Object ( [ATWSError] => [Fields] => [UserDefinedFields] => ) [ReturnCode] => 1 ) )
#kunal
output
ATWS\AutotaskObjects\QueryResponse Object ( [queryResult] => ATWS\AutotaskObjects\ATWSResponse Object ( [EntityResults] => ATWS\AutotaskObjects\ArrayOfEntity Object ( [Entity] => ATWS\AutotaskObjects\Contact Object ( [AccountID] => 236 [Active] => 0 [AdditionalAddressInformation] => [AddressLine] => Dorpstraat [AddressLine1] => [AlternatePhone] => 040-4444555566 [City] => Veldhoven [Country] => Netherlands [CountryID] => 158 [CreateDate] => 2017-11-18T05:36:46.14 [EMailAddress] => Test#email.ciom [Extension] => [ExternalID] => [FaxNumber] => 467863453 [FirstName] => Ellis [LastActivityDate] => 2017-11-18T05:36:46.14 [LastModifiedDate] => 2017-11-18T05:36:46.127 [LastName] => Bommers [MiddleInitial] => [MobilePhone] => 0612312asd35 [Note] => [Notification] => 1 [Phone] => 040-44asd44555566 [RoomNumber] => [State] => NB [Title] => [ZipCode] => 1239aa [Fields] => [UserDefinedFields] => ATWS\AutotaskObjects\ArrayOfUserDefinedField Object ( [UserDefinedField] => ) [id] => 30682996 [BulkEmailOptOut] => [SurveyOptOut] => [FacebookUrl] => [TwitterUrl] => [LinkedInUrl] => [PrimaryContact] => ) ) [EntityResultType] => contact [EntityReturnInfoResults] => ATWS\AutotaskObjects\ArrayOfEntityReturnInfo Object ( [EntityReturnInfo] => ATWS\AutotaskObjects\EntityReturnInfo Object ( [DatabaseAction] => None [DuplicateStatus] => ATWS\AutotaskObjects\EntityDuplicateStatus Object ( [Found] => [Ignored] => [MatchInfo] => [Fields] => [UserDefinedFields] => ) [EntityId] => 30682996 [Message] => [Fields] => [UserDefinedFields] => ) [Fields] => [UserDefinedFields] => ) [Errors] => ATWS\AutotaskObjects\ArrayOfATWSError Object ( [ATWSError] => [Fields] => [UserDefinedFields] => ) [ReturnCode] => 1 ) )
Notice: Undefined property: ATWS\AutotaskObjects\ArrayOfUserDefinedField::$EntityReturnInfoResults in C:\xampp\htdocs\Api\Autotask\vendor\test.php on line 35
Notice: Trying to get property of non-object in C:\xampp\htdocs\Api\Autotask\vendor\test.php on line 35
Notice: Trying to get property of non-object in C:\xampp\htdocs\Api\Autotask\vendor\test.php on line 35
Notice: Trying to get property of non-object in C:\xampp\htdocs\Api\Autotask\vendor\test.php on line 35
Array
<?php
namespace ATWS\AutotaskObjects;
class Contact extends Entity
{
public $AccountID;
public $Active;
public $AdditionalAddressInformation;
public $AddressLine;
public $AddressLine1;
public $AlternatePhone;
public $City;
public $Country;
public $CountryID;
public $CreateDate;
public $EMailAddress;
public $Extension;
public $ExternalID;
public $FaxNumber;
public $FirstName;
public $LastActivityDate;
public $LastModifiedDate;
public $LastName;
public $MiddleInitial;
public $MobilePhone;
public $Note;
public $Notification;
public $Phone;
public $RoomNumber;
public $State;
public $Title;
public $ZipCode;
}
If i understand your problem you are looking for this:-
echo $json->queryResult->EntityResults->Entity->UserDefinedFields->UserDefinedField->EntityReturnInfoResults->DatabaseAction->EntityReturnInfo->EntityId;
I'm using JAXL 3.x to write a module that allow me to send a message to another facebook user.
public function sendTo($id = null, $name = null, $user = null){
if(!$id)
throw new NotFoundException(__('Invalid user id'));
if(!$name)
throw new NotFoundException(__('Invalid name'));
if(!$user)
throw new NotFoundException(__('Invalid user'));
$this->set('mess',$_POST['mess']);
$this->set('id',$id);
$this->set('name',$name);
$config = new Config();
$client = new JAXL(array(
// (required) credentials
'jid' => $id,
'fb_app_key' => $config->fb_app_id,
'fb_access_token' => $config->fb_access_token,
// force tls (facebook require this now)
'force_tls' => true,
// (required) force facebook oauth
'auth_type' => 'X-FACEBOOK-PLATFORM',
// (optional)
//'resource' => 'resource',
'log_level' => JAXL_INFO
));
//
// add necessary event callbacks here
//
$client->add_cb('on_auth_success', function() {
echo "got on_auth_success cb, jid ".$client->full_jid->to_string();
});
$client->add_cb('on_auth_failure', function($reason) {
$client->send_end_stream();
echo "got on_auth_failure cb with reason $reason";
});
$client->add_cb('on_chat_message', function($stanza) {
// echo back incoming message stanza
$stanza->to = $id;
$stanza->from = $client->full_jid->to_string();
$client->send($stanza);
});
$client->add_cb('on_disconnect', function() {
echo "got disconnected";
});
//
// finally start configured xmpp stream
//
$client->start();
echo "done\n";
}
But it turned out to me an error with a null $client after enter 'on_auth_success'. But as you see in the code, after the $client was created, i tried tyo print out its' content by print_r($client); and result is:
JAXL Object ( [cfg] => Array ( [jid] => -to_some_one#chat.facebook.com [fb_app_key] => appid [fb_access_token] => access_token [force_tls] => 1 [auth_type] => X-FACEBOOK-PLATFORM [log_level] => 4 [host] => chat.facebook.com [port] => 5222 ) [ev:protected] => JAXLEvent Object ( [common:protected] => Array ( ) [reg] => Array ( ) ) [xeps] => Array ( [0030] => XEP_0030 Object ( [jaxl:protected] => JAXL Object *RECURSION* ) [0115] => XEP_0115 Object ( [jaxl:protected] => JAXL Object *RECURSION* ) ) [roster] => Array ( ) [manage_roster] => 1 [manage_subscribe] => none [log_level] => 4 [priv_dir] => C:\xampp\htdocs\cake\app\Lib\Facebook/.jaxl [tmp_dir] => C:\xampp\htdocs\cake\app\Lib\Facebook/.jaxl/tmp [log_dir] => C:\xampp\htdocs\cake\app\Lib\Facebook/.jaxl/log [pid_dir] => C:\xampp\htdocs\cake\app\Lib\Facebook/.jaxl/run [sock_dir] => C:\xampp\htdocs\cake\app\Lib\Facebook/.jaxl/sock [sock:JAXL:private] => [cli:JAXL:private] => [local_ip] => 172.17.1.137 [pid] => 4736 [mode] => apache2handler [status] => [features] => Array ( ) [category] => client [type] => bot [lang] => en [retry] => 1 [retry_interval:JAXL:private] => 1 [retry_attempt:JAXL:private] => 0 [retry_max_interval:JAXL:private] => 32 [full_jid] => [jid] => XMPPJid Object ( [node] => -ffff[domain] => chat.facebook.com [resource] => [bare] => -fffff#chat.facebook.com ) [pass] => [resource] => jaxl#f2991f0002fbd1af8df4754c1df8683c [force_tls] => 1 [trans:protected] => JAXLSocketClient Object ( [host:JAXLSocketClient:private] => [port:JAXLSocketClient:private] => [transport:JAXLSocketClient:private] => [stream_context:JAXLSocketClient:private] => [blocking:JAXLSocketClient:private] => [fd] => [errno] => [errstr] => [timeout:JAXLSocketClient:private] => 10 [ibuffer:JAXLSocketClient:private] => [obuffer:JAXLSocketClient:private] => [compressed:JAXLSocketClient:private] => [recv_bytes:JAXLSocketClient:private] => 0 [send_bytes:JAXLSocketClient:private] => 0 [recv_cb:JAXLSocketClient:private] => Array ( [0] => JAXLXmlStream Object ( [delimiter:JAXLXmlStream:private] => \ [ns:JAXLXmlStream:private] => [parser:JAXLXmlStream:private] => Resource id #93 [stanza:JAXLXmlStream:private] => [depth:JAXLXmlStream:private] => -1 [start_cb:JAXLXmlStream:private] => Array ( [0] => JAXL Object *RECURSION* [1] => start_cb ) [stanza_cb:JAXLXmlStream:private] => Array ( [0] => JAXL Object *RECURSION* [1] => stanza_cb ) [end_cb:JAXLXmlStream:private] => Array ( [0] => JAXL Object *RECURSION* [1] => end_cb ) ) [1] => parse ) [recv_chunk_size:JAXLSocketClient:private] => 1024 [writing:JAXLSocketClient:private] => ) [xml:protected] => JAXLXmlStream Object ( [delimiter:JAXLXmlStream:private] => \ [ns:JAXLXmlStream:private] => [parser:JAXLXmlStream:private] => Resource id #93 [stanza:JAXLXmlStream:private] => [depth:JAXLXmlStream:private] => -1 [start_cb:JAXLXmlStream:private] => Array ( [0] => JAXL Object *RECURSION* [1] => start_cb ) [stanza_cb:JAXLXmlStream:private] => Array ( [0] => JAXL Object *RECURSION* [1] => stanza_cb ) [end_cb:JAXLXmlStream:private] => Array ( [0] => JAXL Object *RECURSION* [1] => end_cb ) ) [last_id:protected] => 0 [state:protected] => setup )
That means $client was success in connecting to XMPP service. Any helps?
\\\\\\\\ADDING COMMENT\\\\\\\\\
I'm using cakephp in developing web apps.
hi i am using facebook graph api PHP SDK . here i am trying to get the logged in user's facebook details , currently i am getting only the basic details which are not required any permissions .
Array
(
[id] => xxxxxxxxx
[name] => Kanishka Bandara Panamaldeniya
[first_name] => Kanishka
[middle_name] => Bandara
[last_name] => Panamaldeniya
[link] => http://www.facebook.com/kanishka.panamaldeniya
[username] => kanishka.panamaldeniya
[hometown] => Array
(
[id] => 108014839219027
[name] => Kandy
)
[location] => Array
(
[id] => 108602292505393
[name] => Colombo, Sri Lanka
)
[quotes] => every action has a reaction....
[work] => Array
(
[0] => Array
(
[employer] => Array
(
[id] => 234117399957729
[name] => Cyber LMJ
)
[location] => Array
(
[id] => 108602292505393
[name] => Colombo, Sri Lanka
)
[position] => Array
(
[id] => 109542932398298
[name] => Software Engineer
)
[start_date] => 2011-08
)
[1] => Array
(
[employer] => Array
(
[id] => 235852306375
[name] => eMarketingEye
)
[position] => Array
(
[id] => 109542932398298
[name] => Software Engineer
)
[start_date] => 2010-09
[end_date] => 2011-08
)
)
[sports] => Array
(
[0] => Array
(
[id] => 103992339636529
[name] => Cricket
)
)
[favorite_teams] => Array
(
[0] => Array
(
[id] => 191485640872790
[name] => Sri Lanka Cricket Team
)
)
[favorite_athletes] => Array
(
[0] => Array
(
[id] => 185101794860886
[name] => Kumara Sangakkara
)
[1] => Array
(
[id] => 119473804782315
[name] => Angelo Mathews
)
[2] => Array
(
[id] => 164574093575397
[name] => Kumar Sangakkara
)
[3] => Array
(
[id] => 169411436417102
[name] => Virat Kohli
)
[4] => Array
(
[id] => 166273026737204
[name] => Lahiru Thirimanne
)
[5] => Array
(
[id] => 101237886616765
[name] => Dinesh Chandimal
)
)
[education] => Array
(
[0] => Array
(
[school] => Array
(
[id] => 34663330581
[name] => Dharmaraja College-Kandy
)
[year] => Array
(
[id] => 138383069535219
[name] => 2005
)
[type] => High School
)
[1] => Array
(
[school] => Array
(
[id] => 112872282058324
[name] => University of Colombo School of Computing
)
[year] => Array
(
[id] => 140617569303679
[name] => 2007
)
[type] => College
)
[2] => Array
(
[school] => Array
(
[id] => 107577089271805
[name] => University of Colombo
)
[type] => Graduate School
[with] => Array
(
[0] => Array
(
[id] => 705760115
[name] => Lasitha Benaragama
)
)
)
)
[gender] => male
[timezone] => 5.5
[locale] => en_US
[languages] => Array
(
[0] => Array
(
[id] => 104023029632921
[name] => Sinhala
)
[1] => Array
(
[id] => 106059522759137
[name] => English
)
)
[verified] => 1
[updated_time] => 2012-07-29T16:34:22+0000
)
now i want to get fields
*email
*birth day
and some other permission requesting fields .
so i am doing
$this->co_config_items = $this->ci->config->item('connections_config');
$fbconfig = array(
'appId' => $this->co_config_items['fb_appid'],
'secret' => $this->co_config_items['fb_secret'],
'cookie' => true,
'domain' => $this->ci->config->item('domain')
);
$this->ci->load->library('3rd/connectors/facebook', $fbconfig);
$facebook = new Facebook($fbconfig);
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 2;
$session = $facebook->getSession();
$url = $facebook->getLoginUrl(array(
'canvas' => 1,
'fbconnect' => 0,
'scope' => 'read_stream,friends_likes,user_birthday'
));
if(!$session){
$url = $facebook->getLoginUrl(array(
'canvas' => 1,
'fbconnect' => 0,
'scope' => 'read_stream,friends_likes,user_birthday'
));
echo "<script type='text/javascript'>window.location = '$url';</script>";
}
else{
//echo "<script type='text/javascript'>window.opener.location.href='" . base_url() . "home/auth/get_user_facebook_details_list" . "'; self.close();
//</script>";
try {
$me = $facebook->api('/me');
$this->ci->session->set_flashdata ( 'user_details',$me);
$url=base_url()."home/auth/user_contact_information";
echo "<script type='text/javascript'>window.opener.location.href = '$url';self.close();</script>";
} catch (FacebookApiException $e) {
$this->ci->message->set_error(array('An errror occured , please try again'));
}
}
i am trying to ask permissions by
$url = $facebook->getLoginUrl(array(
'canvas' => 1,
'fbconnect' => 0,
'scope' => 'read_stream,friends_likes,user_birthday'
)):
but it is not asking for any permission , the default array is always printing . why is that . please help . thanks in advance
Try doing this instead:
$url = $facebook->getLoginUrl(array('scope' => 'read_stream,friends_likes,user_birthday'));
i was using the version 2 of PHP sdk , now i am using version 3 , now it is working , thank you very much . i saw some changes in two versions in this function
version 2
public function getLoginUrl($params=array()) {
$currentUrl = $this->getCurrentUrl();
return $this->getUrl(
'www',
'login.php',
array_merge(array(
'api_key' => $this->getAppId(),
'cancel_url' => $currentUrl,
'display' => 'page',
'fbconnect' => 1,
'next' => $currentUrl,
'return_session' => 1,
'session_version' => 3,
'v' => '1.0',
), $params)
);
}
version 3
public function getLoginUrl($params=array()) {
$this->establishCSRFTokenState();
$currentUrl = $this->getCurrentUrl();
// if 'scope' is passed as an array, convert to comma separated list
$scopeParams = isset($params['scope']) ? $params['scope'] : null;
if ($scopeParams && is_array($scopeParams)) {
$params['scope'] = implode(',', $scopeParams);
}
return $this->getUrl(
'www',
'dialog/oauth',
array_merge(array(
'client_id' => $this->getAppId(),
'redirect_uri' => $currentUrl, // possibly overwritten
'state' => $this->state),
$params));
}
in version 3 this i can see this additional code
// if 'scope' is passed as an array, convert to comma separated list
$scopeParams = isset($params['scope']) ? $params['scope'] : null;
if ($scopeParams && is_array($scopeParams)) {
$params['scope'] = implode(',', $scopeParams);
}
in version 2 , there is nothing called scope .and also
in version 2
return $this->getUrl(
'www',
'login.php',
in version 3
return $this->getUrl(
'www',
'dialog/oauth',
I'm working with an object that returns information in a format like the following... I've removed some details where the information gets a little repetitive to save some space.
ISC_QUOTE_ITEM Object (
[type:protected] => 1
[id:protected] => 4cff5974138c9
[hash:protected] => cd2a8393493a286cf1fe97d92a947719
[productData:protected] =>
[productId:protected] => 28
[variationId:protected] => 0
[variationOptions:protected] => Array ( )
[quantity:protected] => 1
[originalOrderQuantity:protected] => 0
[name:protected] => Mac Pro
[basePrice:protected] => 2799.0000
[sku:protected] =>
[wrapping:protected] => Array ( )
[configuration:protected] => Array ( )
[eventDate:protected] => Array ( )
[eventName:protected] =>
[parentId:protected] =>
[quote:protected] => ISC_QUOTE Object (
[customerId:protected] =>
[customerGroupId:protected] =>
[discounts:protected] => Array ( )
[addresses:protected] => Array (
[4cff2f55b0fcd] => ISC_QUOTE_ADDRESS_SHIPPING Object (
[shippingMethod:protected] =>
[shippingCache:protected] =>
[handlingCost:protected] => 0
[quote:protected] => ISC_QUOTE Object *RECURSION*
[type:protected] => shipping
[id:protected] => 4cff2f55b0fcd
[firstName:protected] => asd
[lastName:protected] => asd
[company:protected] => asd
[phone:protected] => asd
[email:protected] => sz#gmail.com
[address1:protected] => asd
[address2:protected] =>
[zip:protected] => 62990
[city:protected] => asd
[state:protected] => Array (
[id] => 0
[iso2] =>
[name] => asd
)
[country:protected] => Array (
[id] => 99
[name] => India
[iso2] => IN
)
[cachedTotals:protected] => Array ( )
[customFields:protected] => Array ( )
[saveAddress:protected] =>
[customerAddressId:protected] => 0
)
[4cff2f55cc2b6] => ISC_QUOTE_ADDRESS Object (
[handlingCost:protected] =>
[quote:protected] => ISC_QUOTE Object *RECURSION*
[type:protected] => billing
[id:protected] => 4cff2f55cc2b6
[firstName:protected] => asd
[lastName:protected] => asd
[company:protected] => asd
[phone:protected] => asd
[email:protected] => sz#gmail.com
[address1:protected] => asd
[address2:protected] =>
[zip:protected] => 62990
[city:protected] => asd
[state:protected] => Array (
[id] => 0
[iso2] =>
[name] => asd
)
[country:protected] => Array (
[id] => 99
[name] => India
[iso2] => IN
)
[cachedTotals:protected] => Array ( )
[customFields:protected] => Array ( )
[saveAddress:protected] =>
[customerAddressId:protected] => 0
)
)
[coupons:protected] => Array ( )
[giftCertificates:protected] => Array ( )
[items:protected] => Array (
[0] => ISC_QUOTE_ITEM Object (
[type:protected] => 1
[id:protected] => 4cff2f55b11d2
[hash:protected] => 587e0ee453488554f782b20f3c928916
[productData:protected] =>
[productId:protected] => 24
[variationId:protected] => 0
[variationOptions:protected] => Array ( )
[quantity:protected] => 3
[originalOrderQuantity:protected] => 0
[name:protected] => Apple iPod Socks
[basePrice:protected] => 29.0000
[sku:protected] =>
[wrapping:protected] => Array ( )
[configuration:protected] => Array ( )
[eventDate:protected] => Array ( )
[eventName:protected] =>
[parentId:protected] =>
[quote:protected] => ISC_QUOTE Object *RECURSION*
[discounts:protected] => Array ( )
[isCustomPrice:protected] =>
[addressId:protected] => 4cff2f55b0fcd
[cachedTotals:protected] => Array ( )
[inQuote:protected] => 1
[inventoryChecking:protected] => 1
[weight:protected] => 1.0000
[fixedShippingCost:protected] => 0.0000
)
[1] => ISC_QUOTE_ITEM Object (
[type:protected] => 1
[id:protected] => 4cff58167d29f
[hash:protected] => 1da6aa898763172b8f7b9d8097d37f42
[productData:protected] =>
[productId:protected] => 23
[variationId:protected] => 0
[variationOptions:protected] => Array ( )
[quantity:protected] => 1
[originalOrderQuantity:protected] => 0
[name:protected] => Apple In-Ear Headphones with Remote and Mic
[basePrice:protected] => 79.0000
[sku:protected] =>
[wrapping:protected] => Array ( )
[configuration:protected] => Array ( )
[eventDate:protected] => Array ( )
[eventName:protected] =>
[parentId:protected] =>
[quote:protected] => ISC_QUOTE Object *RECURSION*
[discounts:protected] => Array ( )
[isCustomPrice:protected] =>
[addressId:protected] => 4cff2f55b0fcd
[cachedTotals:protected] => Array ( )
[inQuote:protected] => 1
[inventoryChecking:protected] => 1
[weight:protected] => 2.0000
[fixedShippingCost:protected] => 0.0000
)
[2] => ISC_QUOTE_ITEM Object *RECURSION*
)
[isSplitShipping:protected] =>
[cachedTotals:protected] => Array ( )
[hasFreeShipping:protected] =>
[appliedStoreCredit:protected] => 0
[appliedDiscountRules:protected] => Array ( )
[customerMessage:protected] =>
[staffNotes:protected] =>
[orderStatus:protected] => 0
[orderId:protected] =>
[discountsEnabled:protected] => 1
)
[discounts:protected] => Array ( )
[isCustomPrice:protected] =>
[addressId:protected] => 4cff2f55b0fcd
[cachedTotals:protected] => Array ( )
[inQuote:protected] => 1
[inventoryChecking:protected] => 1
[weight:protected] => 3.0000
[fixedShippingCost:protected] => 0.0000
)
I need to extract details such as ID, name, etc. so that it reads 4cff5974138c9, Mac Pro, etc. respectively. How can I do that?
You need to call a function of that class (of which ISC_QUOTE_ITEM is an object - say MyClass ) which returns the protected variable
Edit
It can be accessed. I was correct.
Like this -
Add a function inside your class MyClass if you don't already have one.
public function getName()
{
return $this->name;
}
And then in your code you can do this:-
echo $obj->getName();
Read http://php.net/manual/en/language.oop5.visibility.php for details on visibility of types of variables
You can do this by using the reflector construct:
Example taken from http://www.php.net/manual/en/reflectionclass.getproperties.php:
<?php
class Foo {
public $foo = 1;
protected $bar = 2;
private $baz = 3;
}
$foo = new Foo();
$reflect = new ReflectionClass($foo);
$props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED);
foreach ($props as $prop) {
print $prop->getName() . "\n";
}
var_dump($props);
?>
As you can see also the protected $bar is returned :) And have a look at http://www.php.net/manual/en/reflectionproperty.getvalue.php#98643 there it is shown how to return the value of a protected attribute.