Using Zend amazon service, I have fetched till there.
$url=$result->LargeImage->Url;
print_r($url);
the output of this is:
Zend_Uri_Http Object
(
[_username:protected] =>
[_password:protected] =>
[_host:protected] => ecx.images-amazon.com
[_port:protected] =>
[_path:protected] => /images/I/41voDxJS62L.jpg
[_query:protected] =>
[_fragment:protected] =>
[_regex:protected] => Array
(
[escaped] => %[[:xdigit:]]{2}
[unreserved] => [A-Za-z0-9-_.!~*'()\[\]]
[segment] => (?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*'()\[\]:#&=+$,;])*
[path] => (?:\/(?:(?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*'()\[\]:#&=+$,;])*)?)+
[uric] => (?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*'()\[\];\/?:#&=+$,])
)
[_scheme:protected] => http
)
We can't do echo $url->_host:protected here as 'protected' is keyword.
How do I access that?
Can anyone help please?
Thanks
Use the getter.
$result->LargeImage->Url->getHost()
or
$url->getHost()
See the documentation : http://framework.zend.com/apidoc/1.9/Zend_Uri/Zend_Uri_Http.html
Related
I'm using EHttpClient extension yii.
My Code:
$file = file_get_contents($path, true);
Yii::import('ext.EHttpClient.*');
$client = new EHttpClient('https://secure.efaxdeveloper.com/EFax_WebFax.serv', array(
'maxredirects' => 3,
'timeout' => 30,
'Content-Type' => 'application/x-www-form-urlencoded',
'adapter' => 'EHttpClientAdapterCurl'));
$client->setParameterPost(array('id'=>urlencode("2313125942"), 'xml'=>urlencode($file)));
SiteHelper::printShow($client);
$response = $client->request("POST");
var_dump($response->isSuccessful());
SiteHelper::printShow($response);
My xml data:
<?xml version="1.0"?>
<OutboundRequest>
<AccessControl>
<UserName>b23s2323</UserName>
<Password>b23s2323</Password>
</AccessControl>
<Transmission>
<TransmissionControl>
<Resolution>STANDARD</Resolution>
</TransmissionControl>
<DispositionControl>
<DispositionLevel>BOTH</DispositionLevel>
<DispositionEmails>
<DispositionEmail>
<DispositionAddress>johnmorris201615#gmail.com</DispositionAddress>
</DispositionEmail>
</DispositionEmails>
</DispositionControl>
<Recipients>
<Recipient>
<RecipientFax>8189790412</RecipientFax>
</Recipient>
</Recipients>
<Files>
<File>
<FileContents>Base64 pdf here</FileContents>
<FileType>pdf</FileType>
</File>
</Files>
</Transmission>
</OutboundRequest>
The information of my request:
EHttpClient Object
(
[config:protected] => Array
(
[maxredirects] => 3
[strictredirects] =>
[useragent] => EHttpClient
[timeout] => 30
[adapter] => EHttpClientAdapterCurl
[httpversion] => 1.1
[keepalive] =>
[storeresponse] => 1
[strict] => 1
[output_stream] =>
[encodecookies] => 1
[rfc3986_strict] =>
[content-type] => application/x-www-form-urlencoded
)
[adapter:protected] =>
[uri:protected] => EUriHttp Object
(
[_username:protected] =>
[_password:protected] =>
[_host:protected] => secure.efaxdeveloper.com
[_port:protected] => 443
[_path:protected] => /EFax_WebFax.serv
[_query:protected] =>
[_fragment:protected] =>
[_regex:protected] => Array
(
[alphanum] => [^\W_]
[escaped] => (?:%[\da-fA-F]{2})
[mark] => [-_.!~*'()\[\]]
[reserved] => [;\/?:#&=+$,]
[unreserved] => (?:[^\W_]|[-_.!~*'()\[\]])
[segment] => (?:(?:(?:[^\W_]|[-_.!~*'()\[\]])|(?:%[\da-fA-F]{2})|[:#&=+$,;])*)
[path] => (?:\/(?:(?:(?:[^\W_]|[-_.!~*'()\[\]])|(?:%[\da-fA-F]{2})|[:#&=+$,;])*)?)+
[uric] => (?:[;\/?:#&=+$,]|(?:[^\W_]|[-_.!~*'()\[\]])|(?:%[\da-fA-F]{2}))
)
[_scheme:protected] => https
)
[headers:protected] => Array
(
)
[method:protected] => GET
[paramsGet:protected] => Array
(
)
[paramsPost:protected] => Array
(
[id] => 2313125942
[xml] => The%encoded%url%xml%data
)
[cookiejar:protected] =>
[last_request:protected] =>
[last_response:protected] =>
[redirectCounter:protected] => 0
[_unmaskStatus:protected] =>
[_queryBracketsEscaped:protected] => 1
)
I already read the documentation from https://secure.efaxdeveloper.com/downloads.jsp Outbound already set all the required fields on xml data and request post. But I always get this error from efax developer API:
Post Unsuccessful!
Your request has failed due to invalid data.
Please refer to our documentation prior to resubmitting.
Error Level: User
Error Message: XML data argument was not passed.
Please contact us at 888-278-8666 if you continue to encounter errors.
Error Message : XML data argument was not passed What is wrong with my xml data?
(*Note on my request the xml post parameter is set the encoded file contents of my xml).
I used PHP efax instead.
PHP eFax is a PHP class that wraps the eFax® Developer API. Use PHP
eFax to automate the task of sending and receiving faxes
electronically from your PHP-powered web server.
Don't use urlencode. Just set the content type to application/x-www-form-urlencoded.
I am trying to execute queries on statements stored in Learning Locker via PHP and TinCanPHP API. Going by this answer, I was able to fetch a response from Learning Locker. Here is a part of the response:
TinCan\LRSResponse Object
(
[success] => 1
[content] => TinCan\StatementsResult Object
(
[statements:protected] => Array
(
[0] => TinCan\Statement Object
(
[id:protected] => 9ea9e6b6-8278-4545-a02c-c46113f3ba30
[stored:protected] => 2016-02-28T12:04:01.670600+00:00
[authority:protected] => TinCan\Agent Object
(
[objectType:protected] => Agent
[name:protected] => New Client
[mbox:protected] => mailto:hello#learninglocker.net
[mbox_sha1sum:protected] =>
[openid:protected] =>
[account:protected] =>
)
[version:protected] => 1.0.0
[attachments:protected] => Array
(
)
[actor:protected] => TinCan\Agent Object
(
[objectType:protected] => Agent
[name:protected] => Subhayan Roy
[mbox:protected] => mailto:subhayanroy5#gmail.com
[mbox_sha1sum:protected] =>
[openid:protected] =>
[account:protected] =>
)
[verb:protected] => TinCan\Verb Object
(
[id:protected] => http://activitystrea.ms/schema/1.0/search
[display:protected] => TinCan\LanguageMap Object
(
[_map:protected] => Array
(
[en-US] => Searched
)
)
)
The list of statements returned has permission protected, so I'm not being able to access them. How do I access the statements? What am I missing here?
You need to use the methods built into the library. In this case the one you want is getStatements.
$statementResult->content->getStatements();
See the documentation here: http://rusticisoftware.github.io/TinCanPHP/doc/api/latest/classes/TinCan.StatementsResult.html#method_getStatements
To answer the question which you will ask next (Why aren't I getting all statements returned in the result?), Take a look at the Statement Result getMore method which gives you the more URL and the Remote LRS moreStatements method which accepts a more URL and fetches the next batch of statements. See this code sample: https://github.com/garemoko/TinBadgesPHP/blob/b8789042f4af23f0f7927596e8e7f2a06655db72/TinBadges/RemoteLRS.php#L84-L96
For some reason when I print_r a variable containing an object I get data. However when I try to access each item using the -> notation it says it is NULL.
Here is the print_r dump of $user_data:
STDCLASS OBJECT (
[UACC_ID] => 6
[UACC_GROUP_FK] => 1
[UACC_EMAIL] => xxx#GMAIL.COM
[UACC_USERNAME] => xxxx
[UACC_PASSWORD] => $2A$08$CLSxxxxxxEOS7D2NDCSDD3P6A6
[UACC_IP_ADDRESS] => xx.xxx.xx.65
[UACC_SALT] => C64JYWY7ZS
[UACC_ACTIVATION_TOKEN] =>
[UACC_FORGOTTEN_PASSWORD_TOKEN] =>
[UACC_FORGOTTEN_PASSWORD_EXPIRE] => 0000-00-00 00:00:00
[UACC_UPDATE_EMAIL_TOKEN] =>
[UACC_UPDATE_EMAIL] =>
[UACC_ACTIVE] => 1
[UACC_SUSPEND] => 0
[UACC_FAIL_LOGIN_ATTEMPTS] => 0
[UACC_FAIL_LOGIN_IP_ADDRESS] =>
[UACC_DATE_FAIL_LOGIN_BAN] => 0000-00-00 00:00:00
[UACC_DATE_LAST_LOGIN] => 2013-05-05 07:18:34
[UACC_DATE_ADDED] => 2013-04-28 09:34:39
[UGRP_ID] => 1
[UGRP_NAME] => PUBLIC
[UGRP_DESC] => PUBLIC USER : HAS NO ADMIN ACCESS RIGHTS.
[UGRP_ADMIN] => 0
[UPRO_ID] => 6
[UPRO_UACC_FK] => 6
[UPRO_COMPANY] =>
[UPRO_FIRST_NAME] => xxxx
[UPRO_LAST_NAME] => xxxxx
[UPRO_PHONE] => 01392
[UPRO_NEWSLETTER] => 0
[UADD_ID] =>
[UADD_UACC_FK] =>
[UADD_ALIAS] =>
[UADD_RECIPIENT] =>
[UADD_PHONE] =>
[UADD_COMPANY] =>
[UADD_ADDRESS_01] =>
[UADD_ADDRESS_02] =>
[UADD_CITY] =>
[UADD_COUNTY] =>
[UADD_POST_CODE] =>
[UADD_COUNTRY] =>
)
However, when I try this I get NULL:
var_dump($user_data->UACC_ID);
I can't seem to echo anything by using the notation $user_data->UACC_EMAIL etc. What am I doing wrong?
Thank you all. It appears the output was being converted to ALLCAPS in CSS and so I didn't realise that the library actually uses the lower case variants.
Thanks.
One possibilities, however strange, is that the object has a __get function defined to capture and return null on internal private data points, to prevent php from throwing fatal "cant access private" errors if you try accessing any data directly.
so, yes, UACC_ID exists, and is in there, but is being intercepted.
I am doing the login using twitter oauth functionality. I am getting the following object from $client = $token->getHttpClient($config) method:
Zend_Oauth_Client Object
(
[_config:protected] => Zend_Oauth_Config Object
(
[_signatureMethod:protected] => HMAC-SHA1
[_requestScheme:protected] => header
[_requestMethod:protected] => POST
[_version:protected] => 1.0
[_callbackUrl:protected] => http://roomstayssvn.com/register/twittercallback
[_siteUrl:protected] => http://twitter.com/oauth
[_requestTokenUrl:protected] =>
[_accessTokenUrl:protected] =>
[_authorizeUrl:protected] =>
[_consumerKey:protected] => b04fuaxLR2d035FN8tTkQ
[_consumerSecret:protected] => NGPPovdXDnSpivNoMNIgA609ZJIB8GVKGgs6yEF8A
[_rsaPrivateKey:protected] =>
[_rsaPublicKey:protected] =>
[_token:protected] => Zend_Oauth_Token_Access Object
(
[_params:protected] => Array
(
[oauth_token] => 299516752-tksjJZUR7Q2gwrDRDpLOLCrYhySTGWz1SBwTKcRU
[oauth_token_secret] => 7S9R2FLuB0GT4vvy0GerThUnpkbSTeSalURib48Sx20
[user_id] => 299516752
[screen_name] => jogkunal5
)
)
.....
..... and so on
I want to print user_id and screen_name. How can I print it?
Following should work
$user_id = $client->getToken()->getParam('user_id');
$screen_name = $client->getToken()->getParam('screen_name');
Zend_Oauth_Client::__call() proxies any method of Zend_Oauth_Config.
Zend_Oauth_Config::getToken() returns Zend_Oauth_Token
Zend_Oauth_Token::getParam() gets the value for a parameter
Read the docs from here.
Its better you use a Good IDE that supports Zend framework.
I have a data that came from a session and I want to parse base on regex. Below are the 3 data that I want to get login, firstName and lastName.
login = James
firstName = James.S
lastName = Steal
Array (
[user] => __PHP_Incomplete_Class Object (
[__PHP_Incomplete_Class_Name] => DEX_User
[permissionID:DE_User:private] => 9
[login:DE_User:private] => James.S
[email:DE_User:private] => james.s#domain.com
[firstName:DE_User:private] => James
[lastName:DE_User:private] => Steal
[title:DE_User:private] => Warehouse Man
[manager:DE_User:private] => Manager's Name
[workPhone:DE_User:private] => +1 (111) 111-1111
[mobilePhone:DE_User:private] => +1 (222) 222-2222
[homePhone:DE_User:private] => +1 (333) 333-3333
[im:DE_User:private] =>
[timeDelta:DE_User:private] => Asia/Hongkong
[lastLogin:DE_User:private] => __PHP_Incomplete_Class Object (
[__PHP_Incomplete_Class_Name] => GB_Date
[valueStored:protected] => 13545544126666309821
[mode:protected] => BASE
[master:protected] =>
)
[description:DE_User:private] => Warehouse Engineer
[isActive:DE_User:private] => __PHP_Incomplete_Class Object (
[__PHP_Incomplete_Class_Name] => GB_Boolean
[valueStored:protected] => 1
[mode:protected] => BASE
[master:protected] =>
)
[isTerminate:DE_User:private] => __PHP_Incomplete_Class Object (
[__PHP_Incomplete_Class_Name] => GB_Boolean
[valueStored:protected] =>
[mode:protected] => BASE
[master:protected] =>
)
[id:protected] => 231968
[isModifyed:protected] =>
[needInsert:protected] =>
[isDeleted] =>
[isRemoved] =>
)
[enter_password] => 2asas(qwqw)
I tried to perform regexp '/\[[\/]?[A-Za-z0-9]+\]/'; but i can only get that inside the bracket.
Thank you.
Instead of parsing it using RegExp you may evaluate it.
Take a look at var_export($_SESSION['user']); . This returns a parseable string, the only problem you will see there is :
__PHP_Incomplete_Class::__set_state
"__PHP_Incomplete_Class" means, the class was unknown when the Session was started, the string still can't be parsed.
But you can take the string returned by var_export($_SESSION['user'],true) , replace the occurences of __PHP_Incomplete_Class::__set_state with array and the string can be evaluated:
eval('$user='.str_replace('__PHP_Incomplete_Class::__set_state',
'array',
var_export($_SESSION['user'],true)).';');
echo $user[0]['login'].',<br/>'.
$user[0]['firstName'].',<br/>'.
$user[0]['lastName'];