How read pubdate field using willvincent/feeds plugin? - laravel-5

I use https://github.com/willvincent/feeds for reading rss and with all field I also need to get pubDate field.
iI did not find a method for it(I looked also in source app/library/AppRssImport.php file ) and I made some debugging, so methods
echo '<pre>$RssItem->data[\'child\']::'.print_r($RssItem->data['child'],true).'</pre>';
dd($RssItem->data['child']);
has next output:
$RssItem->data['child']::Array
(
[] => Array
(
[title] => Array
(
[0] => Array
(
[data] => Man died 'in agony' after stroke amid ambulance delays
[attribs] => Array
(
)
[xml_base] =>
[xml_base_explicit] =>
[xml_lang] =>
)
)
[description] => Array
(
[0] => Array
(
[data] => Michelle Lane has PTSD and flashbacks of her husband screaming in pain as they went to hospital by car.
[attribs] => Array
(
)
[xml_base] =>
[xml_base_explicit] =>
[xml_lang] =>
)
)
[link] => Array
(
[0] => Array
(
[data] => https://www.bbc.co.uk/news/uk-england-nottinghamshire-46795776
[attribs] => Array
(
)
[xml_base] =>
[xml_base_explicit] =>
[xml_lang] =>
)
)
[guid] => Array
(
[0] => Array
(
[data] => https://www.bbc.co.uk/news/uk-england-nottinghamshire-46795776
[attribs] => Array
(
[] => Array
(
[isPermaLink] => true
)
)
[xml_base] =>
[xml_base_explicit] =>
[xml_lang] =>
)
)
[pubDate] => Array
(
[0] => Array
(
[data] => Thu, 10 Jan 2019 10:02:22 GMT
[attribs] => Array
(
)
[xml_base] =>
[xml_base_explicit] =>
[xml_lang] =>
)
)
)
[http://search.yahoo.com/mrss/] => Array
(
[thumbnail] => Array
(
[0] => Array
(
[data] =>
[attribs] => Array
(
[] => Array
(
[width] => 1024
[height] => 576
[url] => http://c.files.bbci.co.uk/15CE0/production/_105121398_michelle-tony.jpg
)
)
[xml_base] =>
[xml_base_explicit] =>
[xml_lang] =>
)
)
)
)
and https://imgur.com/a/wTmd9cV
I tried to read value of pubDate field, but failed. This structure was rather strange for me...
Which is right decision ?

You can use the get_date() method to grab the value of pubDate?
https://github.com/willvincent/feeds this plugin is only a wrapper around SimplePie php extension. You can look into SimplePie documentation for all other available methods. http://simplepie.org/api/class-SimplePie_Item.html.
A usable code might be like this. I used laravel, so the first line of grabbing the feed might be different.
$feed = Feeds::make('https://www.example.com/feed/');
$items = $feed->get_items();
foreach( $items as $key => $item ) {
$title = $item->get_title();
$guid = $item->get_id();
$pub_date = $item->get_date();
}

Related

unable to get user email from payPal response (SDk rest api) in laravel after approved

I am going to integrate paypal in laravel! according to this
[http://www.17educations.com/laravel/paypal-integration-in-laravel/#disqus_thread][1]
Its work fine redirect paypal and verified and transation is done successfull
its ok and got response: as follow:
now how to get Email etc. from this response?
PayPal\Api\Payment Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[id] => PAY-6F912481CR395364MK5L5QFI
[intent] => sale
[state] => approved
[cart] => 4UA93426DX9093236
[payer] => PayPal\Api\Payer Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[payment_method] => paypal
[payer_info] => PayPal\Api\PayerInfo Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[email] => aassuamba99#gmail.com
[first_name] => Amba
[last_name] => Joshi
[payer_id] => 9B8FFYJJZEHM6
[shipping_address] => PayPal\Api\ShippingAddress Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[recipient_name] => Amba Joshi
[line1] => Flat no. 507 Wing A Raheja Residency
[line2] => Film City Road, Goregaon East
[city] => Mumbai
[state] => Maharashtra
[postal_code] => 400097
[country_code] => IN
)
)
[country_code] => IN
[billing_address] => PayPal\Api\Address Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[line1] => Flat no. 507 Wing A Raheja Residency
[line2] => Film City Road, Goregaon East
[city] => Mumbai
[state] => Maharashtra
[postal_code] => 400097
[country_code] => IN
)
)
)
)
)
)
[transactions] => Array
(
[0] => PayPal\Api\Transaction Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[amount] => PayPal\Api\Amount Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[total] => 50.00
[currency] => USD
[details] => PayPal\Api\Details Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
)
)
)
)
[description] => Your transaction description
[item_list] => PayPal\Api\ItemList Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[items] => Array
(
[0] => PayPal\Api\Item Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[name] => HEAD, NECK AND SHOULDER INC. MINI FACIAL MASSAGE
[price] => 50.00
[currency] => USD
[quantity] => 1
)
)
)
[shipping_address] => PayPal\Api\ShippingAddress Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[recipient_name] => Amba Joshi
[line1] => Flat no. 507 Wing A Raheja Residency
[line2] => Film City Road, Goregaon East
[city] => Mumbai
[state] => Maharashtra
[postal_code] => 400097
[country_code] => IN
)
)
)
)
[related_resources] => Array
(
[0] => PayPal\Api\RelatedResources Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[sale] => PayPal\Api\Sale Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[id] => 0W808156RU066263U
[state] => completed
[amount] => PayPal\Api\Amount Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[total] => 50.00
[currency] => USD
[details] => PayPal\Api\Details Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
)
)
)
)
[payment_mode] => INSTANT_TRANSFER
[protection_eligibility] => ELIGIBLE
[protection_eligibility_type] => ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE
[transaction_fee] => PayPal\Api\Currency Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[value] => 2.25
[currency] => USD
)
)
[parent_payment] => PAY-6F912481CR395364MK5L5QFI
[create_time] => 2016-06-08T08:32:59Z
[update_time] => 2016-06-08T08:32:59Z
[links] => Array
(
[0] => PayPal\Api\Links Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[href] => https://api.sandbox.paypal.com/v1/payments/sale/0W808156RU066263U
[rel] => self
[method] => GET
)
)
[1] => PayPal\Api\Links Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[href] => https://api.sandbox.paypal.com/v1/payments/sale/0W808156RU066263U/refund
[rel] => refund
[method] => POST
)
)
[2] => PayPal\Api\Links Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[href] => https://api.sandbox.paypal.com/v1/payments/payment/PAY-6F912481CR395364MK5L5QFI
[rel] => parent_payment
[method] => GET
)
)
)
[soft_descriptor] => PAYPAL *TESTFACILIT
)
)
)
)
)
)
)
)
[redirect_urls] => PayPal\Api\RedirectUrls Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[return_url] => http://localhost/massagess/payment/status?paymentId=PAY-6F912481CR395364MK5L5QFI
[cancel_url] => http://localhost/massagess/payment/status
)
)
[create_time] => 2016-06-08T08:33:00Z
[update_time] => 2016-06-08T08:32:55Z
[links] => Array
(
[0] => PayPal\Api\Links Object
(
[_propMap:PayPal\Common\PayPalModel:private] => Array
(
[href] => https://api.sandbox.paypal.com/v1/payments/payment/PAY-6F912481CR395364MK5L5QFI
[rel] => self
[method] => GET
)
)
)
)
)
Check this methods, preferably i think getPayer() is what u need:
http://paypal.github.io/PayPal-PHP-SDK/docs/class-PayPal.Api.Payment.html

Make a new multi dimensional array from the existing array in smarty

My whole moto in this question is to make a new array from existing array and to reverse the first and second index of array.
I have an array
Array
(
[0] => Array
(
[0] => Array
(
[field] => Array
(
[name] => name
[tabindex] => 0
)
[colspan] => 3
)
)
[1] => Array
(
[0] => Array
(
[field] => Array
(
[name] => sequence
[tabindex] => 0
)
[colspan] => 3
)
)
[2] => Array
(
[0] => Array
(
[field] => Array
(
[name] => description
[tabindex] => 0
)
[colspan] => 3
)
)
[3] => Array
(
[0] => Array
(
[field] => Array
(
[name] => status
[tabindex] => 0
)
[colspan] => 3
)
)
[4] => Array
(
[0] => Array
(
[field] => Array
(
[name] => modified_by_name
[customCode] => {$fields.date_modified.value} {$APP.LBL_BY} {$fields.modified_by_name.value}
[label] => LBL_DATE_MODIFIED
[tabindex] => 0
)
[colspan] => 3
)
)
[5] => Array
(
[0] => Array
(
[field] => Array
(
[name] => created_by_name
[customCode] => {$fields.date_entered.value} {$APP.LBL_BY} {$fields.created_by_name.value}
[label] => LBL_DATE_ENTERED
[tabindex] => 0
)
[colspan] => 3
)
)
[6] => Array
(
[0] => Array
(
[field] => Array
(
[name] =>
)
)
[1] => Array
(
[field] => Array
(
[name] =>
)
)
)
)
Now i have to make a new array with first index on second and second on first index like this But have to do only in smarty not in php etc
Array
(
[0] => Array
(
[0] => Array
(
[field] => Array
(
[name] => name
[tabindex] => 0
)
[colspan] => 3
)
[1] => Array
(
[field] => Array
(
[name] => sequence
[tabindex] => 0
)
[colspan] => 3
)
[2] => Array
(
[field] => Array
(
[name] => description
[tabindex] => 0
)
[colspan] => 3
)
[3] => Array
(
[field] => Array
(
[name] => status
[tabindex] => 0
)
[colspan] => 3
)
[4] => Array
(
[field] => Array
(
[name] => modified_by_name
[customCode] => {$fields.date_modified.value} {$APP.LBL_BY} {$fields.modified_by_name.value}
[label] => LBL_DATE_MODIFIED
[tabindex] => 0
)
[colspan] => 3
)
[5] => Array
(
[field] => Array
(
[name] => created_by_name
[customCode] => {$fields.date_entered.value} {$APP.LBL_BY} {$fields.created_by_name.value}
[label] => LBL_DATE_ENTERED
[tabindex] => 0
)
[colspan] => 3
)
)
)
I think the following might help you.
You could loop the array you have and fill a new array with the values. Lets call the original $firstArray and the new one $newArray. I see that the first item from the subarrays are what you need(and there are no other items apart from 0) so you could do the following:
{$newArray = []}
{foreach $firstArray as $item}
{$newArray[] = $item.0}
{/foreach}
$item.0 selects the first subarray(there are no other). You might have to use $item[0] depending on your smarty version.
If there is more than 1 subarray, then loop $items first before you add an array to the $newArray.
It looks as if there's another array encapsuling your firstArray, so perhaps you need to select the subarray from the main one first....
note: I used smarty 3. Perhaps you use a different version, be sure to check the syntax for your version.

Elasticsearch bool filter query return results

I have an index with mappings:
[test] => Array
(
[mappings] => Array
(
[testype] => Array
(
[properties] => Array
(
[brand_id] => Array
(
[type] => integer
)
[color] => Array
(
[type] => string
[index] => not_analyzed
)
[description] => Array
(
[type] => string
)
[discount] => Array
(
[type] => float
)
[newprice] => Array
(
[type] => float
)
[oldprice] => Array
(
[type] => float
)
[sex] => Array
(
[type] => string
[index] => not_analyzed
)
[store_id] => Array
(
[type] => integer
)
[title] => Array
(
[type] => string
)
)
)
)
)
And trying to filter my data with this query:
Array
(
[index] => test
[type] => testype
[size] => 100
[body] => Array
(
[query] => Array
(
[filtered] => Array
(
[filter] => Array
(
[bool] => Array
(
[must] => Array
(
[term] => Array
(
[brand_id] => 53
[color] => red
)
)
)
)
)
)
)
)
Expecting to get result like SELECT ... WHERE brand_id=53 AND color=red, but have results like brand_id=53 OR color=red. Am i'm missing something?
Actualy, i want to have a filter like SELECT ... WHERE aaaa='a' AND bbbb='b' AND cccc IN (1,2,6,9) AND ddd IN (xxx,yyy)
You have to put the terms in different arrays.
Disclaimer: I guess this syntax is the PHP one, I'm not familiar with it, please forgive any syntax error.
Try this:
[must] => Array
(
[term] => Array
(
[brand_id] => 53
)
[term] => Array
(
[color] => red
)
)
Your last query should look like this:
[must] => Array
(
[term] => Array
(
[aaaa] => 'a'
)
[term] => Array
(
[bbbb] => 'b'
)
[terms] => Array
(
[cccc] => Array(1, 2, 6, 9)
[minimum_should_match] => 1
)
[terms] => Array
(
[dddd] => Array('xxx', 'yyy')
[minimum_should_match] => 1
)
)

How to convert from newsoap to xml using simplexelement,simple_to_string

error_reporting(0);
session_start();
$link=$_POST['Host'];
$_SESSION['Host']=$link;
$client = new SoapClient("http://".$link."/api/soap/?wsdl");
/*api credentials*/
$apiuser=$_POST['User'];
$_SESSION['User']=$apiuser;
$apikey =$_POST['Key'];
$_SESSION['Key']=$apikey;
/*Action to be made */
$action =$_POST['Catalog'];
$_SESSION['Catalog']=$action;
/*Error trapping if in case number will be input*/
if(ctype_alpha(!$action))
{
die('Incorrect format');
}
else
{
$sess_id= $client->login($apiuser, $apikey);
/api login/
echo"Total Active list Product:".(count($client->call($sess_id, $action)));
echo"";
print_r($result=$client->call($sess_id,$action));
echo"";
}
?>
Array
(
[0] => Array
(
[product_id] => 1
[sku] => ROx12345
[name] => acer netbook
[set] => 4
[type] => simple
[category_ids] => Array
(
)
[website_ids] => Array
(
[0] => 1
)
)
[1] => Array
(
[product_id] => 2
[sku] => Cats1234
[name] => starbucks mug
[set] => 4
[type] => simple
[category_ids] => Array
(
)
[website_ids] => Array
(
[0] => 1
)
)
[2] => Array
(
[product_id] => 3
[sku] => samsung2141
[name] => samsung 3110
[set] => 4
[type] => grouped
[category_ids] => Array
(
)
[website_ids] => Array
(
[0] => 1
)
)

Is it possible to get a value from view.yml in an action

I'm wondering if it's possible to get the name of a stylesheet from view.yml in an action, ideally using something as simple as:
sfConfig::get('......');
I'd like to access the existing declaration in view.yml instead of hardcoding it or duplicating it somewhere like app.yml.
Thanks.
If you want to access the current Module's Config, you can use:
sfViewConfigHandler::getConfiguration(array(dirname(__DIR__) . '/config/view.yml'));
It should return something like this:
Array
(
[indexSuccess] => Array
(
[javascripts] => Array
(
[0] => mission-control.js
)
[stylesheets] => Array
(
[0] => control-box.css
[1] => question.css
)
)
[newSuccess] => Array
(
[javascripts] => Array
(
[0] => box-checker.js
[1] => topic.js
)
[stylesheets] => Array
(
[0] => question.css
[1] => topic.css
)
)
[searchSuccess] => Array
(
[javascripts] => Array
(
[0] => topic.js
)
[stylesheets] => Array
(
[0] => topic.css
)
)
[showSuccess] => Array
(
[javascripts] => Array
(
[0] => mission-control.js
)
[stylesheets] => Array
(
[0] => control-box.css
[1] => question.css
)
)
[editSuccess] => Array
(
[javascripts] => Array
(
[0] => box-checker.js
[1] => topic.js
)
[stylesheets] => Array
(
[0] => question.css
[1] => topic.css
)
)
[all] => Array
(
[stylesheets] => Array
(
)
[javascripts] => Array
(
)
)
)

Resources