Parse youtube feed output - parsing

Hello I am having a problem retrieving a value from this link.
So far I've been using this line of code.
$str = "https://gdata.youtube.com/feeds/api/videos/VdbUBcOCU_A";
$blow =(explode("'",$str));
print_r($blow);
And echoes out "Array" would appreciate any help how to retrieve a value from the link. Thanks.

If I am correct, you are using PHP?
Suggest you use Google PHP client library at https://developers.google.com/youtube/2.0/developers_guide_php
For your case, see https://developers.google.com/youtube/2.0/developers_guide_php#Video_Entry_Contents
$videoEntry = $yt->getVideoEntry('VdbUBcOCU_A');
printVideoEntry($videoEntry);
function printVideoEntry($videoEntry)
{
echo 'Video: ' . $videoEntry->getVideoTitle() . "\n";
echo 'Video ID: ' . $videoEntry->getVideoId() . "\n";
echo 'Updated: ' . $videoEntry->getUpdated() . "\n";
}

Related

Slack API not accepting \n for new line when using slash commands

I've built a simple slack integration (slash command) to return names from my table. The result should look like
Name1
Name2
Name3
For this i simply generate a text string like this:
foreach($names as $name) {
$text .= $name . ' \n';
}
The integration itself is working fine, however the result looks like this
Name1 \nName2\n
Looks like this is an issue in slack.
Apparently it can be solved by using double quotes as such: "\n".
Your code will become:
foreach($names as $name) {
$text .= $name . "\n";
}

Fetch Data from Quickbook

Hello guys I'm new to quickbooks. There is some data in quickbooks which I'm trying to retrieve but quickbooks is returning nothing. I can figure out what is it that I'm doing wrong. I'm trying to retrieve data like this
QUICKBOOKS. PHP
$serviceType = IntuitServicesType::QBO;
$realmId = $this->CI->session->userdata('realmId');
$token = unserialize($this->CI->session->userdata('token'));
$requestValidator = new OAuthRequestValidator($token["oauth_token"],
$token["oauth_token_secret"],
$this->CI->config->item('OAUTH_CONSUMER_KEY'),
$this->CI->config->item('OAUTH_CONSUMER_SECRET'));
$serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator);
$dataService = new DataService($serviceContext);
$entities = $dataService->Query("SELECT * FROM SalesReceipt");
error_log(print_r($entities , true));
can somebody tell me what is it that I'm doing wrong. Thanks
The first thing you should do in a case like this, is turn on logging, and post the logs.
There is not much anyone can tell you here without seeing your logs.
With that said, it's worth nothing that this error:
instead of dataservice I tried using QuickBooks_IPP_Services_SalesReceipt but it's giving me a error salesrecipt class is not defined
Is because that class is from a totally separate, unrelated PHP code library. If you want to use that class, then what you should do is:
Get code from here: https://github.com/consolibyte/quickbooks-php
Follow the quick-start guide linked on that page.
You should end up with code that looks like this:
.
$SalesReceiptService = new QuickBooks_IPP_Service_SalesReceipt();
$salesreceipts = $SalesReceiptService->query($Context, $realm, "SELECT * FROM SalesReceipt STARTPOSITION 1 MAXRESULTS 10");
foreach ($salesreceipts as $SalesReceipt)
{
print('Receipt # ' . $SalesReceipt->getDocNumber() . ' has a total of $' . $SalesReceipt->getTotalAmt() . "\n");
}
If you still have trouble, you can get the HTTP request/response like this:
print($IPP->lastError($Context));
print("\n\n\n\n");
print('Request [' . $IPP->lastRequest() . ']');
print("\n\n\n\n");
print('Response [' . $IPP->lastResponse() . ']');
More examples can be found here:
https://github.com/consolibyte/quickbooks-php/tree/master/docs/partner_platform/example_app_ipp_v3

how to get real link from wordpress api

im using wordpress permalink "post name" %postname%/
so my page link looks like this :
http://designonsky.com/sample-page/
but i want to get the real link :
http://designonsky.com/?page_id=2
im asking if there's a wordpress function ( or php function ) to do that .
no .htaccess please .
sorry for my english
thanks advanced!
Not tested, you could use something like:
if( is_page() ){
echo home_url() . '/?pageid=' . get_the_ID();
}
elseif( is_single() ){
echo home_url() . '/?p=' . get_the_ID();
}
elseif ( is_category() ){
echo home_url() . '/?cat=' . get_the_ID();
}
You can use get_the_ID method to return the current page or post id.

Simple HTML Dom Parser: How to insert to elements

I am trying to insert (append) into an element ... "body" specifically.
I am able to do this this way at the moment:
$var = "some JS stuff";
$e = $htmlDOM->find("body", 0);
$e->outertext = '<body>' . $e->innertext . $var . '</body>';
My issue is that this fixes <body> but the actual html might have js or id etc attached to <body> and I will like to maintain that if it is the case.
The docs don't seem to show a method for this.
Is it possible?
After looking at the source code, I found that the way to go about it is to use
$var = "some JS stuff";
$e = $htmlDOM->find("body", 0);
$e->outertext = $e->makeup() . $e->innertext . $var . '</body>';
That is, the undocumented makeup() function will build the tag and any associated text/code.

php.ini path inside code

To get php.ini path i simply run
<?php
phpinfo();
?>
what is the way to get the php.ini path to show to the user. without showing the whole phpinfo file.
phpinfo(INFO_GENERAL) would be smaller
http://us3.php.net/manual/en/function.phpinfo.php
If you have PHP 5.2.4 or later, you can simply use the php_ini_loaded_file() method which returns the path as a string.
If you don't have that version, here's one way.
ob_start();
phpinfo(INFO_GENERAL);
$data = ob_get_contents();
ob_end_clean();
$lines = explode("\n", $data);
foreach($lines as $line){
list($name, $value) = explode("=>", $line);
if (trim($name) == 'Loaded Configuration File') break;
}
echo $name . ' - ' . $value."\n";
That simply prints:
Loaded Configuration File -
/etc/php5/cli/php.ini
Of course you could use a regex match or something fancier like that if you wanted to.

Resources