ADVISE: Accessing PHP Objects in Internet Explorer from Excel VBA - php

I am trying to automate an excel upload process we have into our data warehouse. From Excel VBA, I am initiating an IE session to our data warehouse > login with my credentials > then navigate to the page to upload, but this is where I am having my problems.
The URL does not change when navigating this website, it is coded in PHP I believe. Therefore, I need to click the specific image - but I do not know how.
In my code below, I added my comments and the error message I receive when debugging. I also added an image of the website, the button I am trying to hit, and inspect of the element. Please help and thank you all in advance! <3 to Stack Overflow!
Signed, Doug Fresh
Private Sub CommandButton2_Click()
Dim objIE As InternetExplorer
Dim aEle As HTMLLinkElement
Dim ele As Object
Dim y As Integer
Dim result As String
Set objIE = New InternetExplorer
objIE.Visible = True
objIE.navigate "http://kpionline.bitam.com/english/memberlogin.php"
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
objIE.document.getElementById("user_name").Value = "username#bimbo.com" 'not real
objIE.document.getElementById("user_pwd").Value = "Bimbo2017" 'not real
objIE.document.getElementById("Login").Click
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
objIE.navigate "https://kpionline7.bitam.com/artus/genvi_test/LoadStage.php?txtRepositorio=fbm_bmd_0030&txtUser=xxxxxxx&txtPassword=xxxxx"
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
'**************************************************************************
'How do I click this icon???
objIE.document.getElementById("ENL8").getElementsByTagName("img")(0).Click
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
'Please see image for php/js website code
'ERROR: Run-time error '424': Object required
'**************************************************************************
objIE.Quit
End Sub

try objIE.document.getElementById("ENL8").Click

Related

Switching to GetSingleItem instead of findItemsAdvanced with the ebay-api

I am using the ebay-api's to pull out listing information using the itemId the user enters to import the current live auction on ebay into my site. I have been using the FindItemsAdvanced which is pretty straight forward grabbing the information using the SingleXMLElement
$itemid = (string) $xml->searchResult->item->itemId;
$shipcost = (string) $xml->searchResult->item->shippingInfo->shippingServiceCost;
I dont really need to use the FindItemsAdvanced because some information is missing, ie: quantity of a item listed.
I have looked at the documentation for GetSingleItem and it doesnt have a searchResult member, my question is, how is the above done with GetSingleItem to get the details.
This is the process i used but cant grab any details
url2 is - http://open.api.ebay.com/shopping?callname=GetSingleItem&responseencoding=XML&appid=myIdApp&siteid=0&version=967&ItemID=192401461174&IncludeSelector=Details
then the contents
$resp2 = file_get_contents($url2);
then the xml object
$xml2 = new SimpleXMLElement($resp2);
At this stage i have my object but i cant extract any details like a can with FindItemsAdvanced
Thanks to the comments i'm adding more information, the file_get_contents only gives me this
2017-12-24T12:33:55.736Z Success E1033_CORE_APILW_18542200_R1 1033 false 192401461174 2018-01-17T10:29:17.000Z 2017-12-18T10:29:17.000Z http://www.ebay.com/itm/Aspire-CF-SUB-OHM-Mod-Battery-Ecig-Vape-Kit-Carbon-Fibre-Aspire-k3-Samsung-25r-/192401461174 FixedPriceItem wigan, Lancashire PayPal http://thumbs3.ebaystatic.com/pict/1924014611748080_1.jpg https://i.ebayimg.com/00/s/NTQ1WDczMQ==/z/6PkAAOSwttFaD~0~/$_1.PNG?set_id=8800005007 https://i.ebayimg.com/00/s/NzIwWDI5MA==/z/kccAAOSwtGlZCa0C/$_1.JPG?set_id=880000500F https://i.ebayimg.com/00/s/OTAyWDYwMA==/z/Gk8AAOSw42JZCa0D/$_1.JPG?set_id=880000500F https://i.ebayimg.com/00/s/Nzg3WDExODE=/z/eNkAAOSwQcJaBAo8/$_1.JPG?set_id=880000500F https://i.ebayimg.com/00/s/OTAwWDkwMA==/z/zQgAAOSwyP5aD~1K/$_1.JPG?set_id=8800005007 https://i.ebayimg.com/00/s/NTAwWDUwMA==/z/6RIAAOSwttFaD~1L/$_1.PNG?set_id=8800005007 wn69jt 183498 Health & Beauty:E Cigarettes, Vapes & Accs:E Cigarettes, Vapes & Mods 5 improveyourlife Purple 525 100.0 0 31.94 23.9 Active 0 Worldwide UK P23DT21H55M22S 184 26395:183497:183498 GB 14 days Returns Accepted Only if broken Buyer false false 0 1000 New false 0 false true true
I understand i need to get the xml into a string to use namespaces but i'm not sure how to do that. The crazy thing is, the only thing i need out of GetSingleItem is the quantity because FindItemsAdvanced does not have it.
Try using $xml2 = simplexml_load_string($resp2); and then you should be able to get the information needed normally, with $quantity = $xml2->Item->Quantity;.
As a tip, I highly recommend you give a try to this SDK. I am using it for a long time, to manage multiple shops and it's extremely helpful. Saved me a huge amount of time. The guy who created it also made a ton of examples. You could have a look at those before using the SDK, and you'll see how much simpler everything is.

FileMaker - editing container field using php api and Insert from URL script

I am using php api for adding/editing/viewing a FileMaker database. I am using Filemaker pro 14 and FMS 14 in windows environment.
I am having an issue with adding/editing container fields. Tried the solution given in the following link: https://community.filemaker.com/thread/66165
It was success. The FM script is:
Goto Layout[ The layout that shows your container field ]
New Record/Request
Set Variable[$url ; Value:Get(ScriptParameter)]
Insert from URL [Select, No Dialog ; database_name::ContainerField ; $url]
Exit Script
I don't want to add new record. I have several container fields in the layout so it's not a solution to add a record for each one, and I need to be able to modify older records' container fields.
I tried modifying the script as follows:
Go to Layout ["products" (products)]
Go to Record/Request/Page [Last]
Open Record/Request
Set Variable [$url; Value: Get(ScriptParameter)]
Insert from URL [Select, No Dialog; products::brochure; $url]
Exit Script []
note: (Last) parameter is just experimental.
The php script is as follows:
$runscript = $fm->newPerformScriptCommand('products', 'addContainerData', 'http://link_to_uploded_file');
$result = $runscript->execute();
$result returns success, but the file wasn't inserted in the container field.
Somebody pointed to me that to use "Insert from URL" I have to specify a record ID. So I did the follows:
modified the php script to:
$editCommand = $fm->newEditCommand('products', $recordID, $editedData);
$editCommand->setPreCommandScript('addContainerData', 'http://url_to_my_uploaded_file');
$result = $editCommand->execute();
and the FM script (addContainerData) to
Set Variable [$url; Value: Get(ScriptParameter)]
Insert from URL [Select, No Dialog; products::brochure; $url]
Exit Script []
Also the result was success BUT without inserting the file to the container field.
What am I missing? What to do to be able to add container data to new/old records?
A possible workaround is to use PHP functions to encode the file to base 64 and set that value to a text field in FileMaker. Once there, you can have auto enter or a script to take the base 64 value and decode it to a container field. This works well especially for files with smaller file sizes.

Where does the Share button in Google Glass send the data?

I'm just starting to explore the functionalities of Google Glass.
What I'm trying to do is a simple Glassware that receives a video from the user, when the default 'Share' function is used.
I have seen the Quickstart project guide and I managed to upload my video in the python demo project; I also managed to implement the example PHP project code in my server.
However, I still can't figure out what exactly is happening where i tap the "Share" button on my Glass: where is sent the data? To my Glassware, to the generic Mirror API, or somewhere else? I suppose the Share function is doing something similar to what is described in the media upload page, but it's not clear how.
The code of the demo project seems to update the timeline event when I upload a picture/video; but if I'm not wrong, this code is just updating an already existing item with the "I have received your data!" caption.
(I'll report here the relevant code from the Google's notify.php sample: )
switch ($request['collection']) {
case 'timeline':
// Verify that it's a share
foreach ($request['userActions'] as $i => $user_action) {
if ($user_action['type'] == 'SHARE') {
$timeline_item_id = $request['itemId'];
$timeline_item = $mirror_service->timeline->get($timeline_item_id);
// Patch the item. Notice that since we retrieved the entire item above
// in order to access the caption, we could have just changed the text
// in place and used the update method, but we wanted to illustrate the
// patch method here.
$patch = new Google_TimelineItem();
$patch->setText("PHP Quick Start got your photo! " .
$timeline_item->getText());
$mirror_service->timeline->patch($timeline_item_id, $patch);
break;
}
}
...
Where and when is actually received the video? I need to know this in order to perform additional operations when I receive the data.
The shared picture or video is downloaded through the download_attachment function in mirror-client.php of the Quickstart PHP project.
Here is the function:
/**
* Download an attachment's content.
*
* #param string item_id ID of the timeline item the attachment belongs to.
* #param Google_Attachment $attachment Attachment's metadata.
* #return string The attachment's content if successful, null otherwise.
*/
function download_attachment($item_id, $attachment) {
$request = new Google_HttpRequest($attachment->getContentUrl(), 'GET', null, null);
$httpRequest = Google_Client::$io->authenticatedRequest($request);
if ($httpRequest->getResponseHttpCode() == 200) {
return $httpRequest->getResponseBody();
} else {
// An error occurred.
return null;
}
}

How to grab data from the script protected site with Excel VBA?

I can't import data table from the site which contain stock data. I did in MS Excel 2007; Data > Get External Data > From Web > Import as usual but there have no return from sites. When I tried to grab data table from the site its shown a small window massage (screenshot), I think the process redirecting to another link; but ultimate result is zero. I think the page is script protected.
Redirecting massage: "Opening: 'http://www.dsebd.org/latest_share_price_all.php"
Please advice me how could I download ( import) data from such site in my Excel Workbook.
The site original link: http://www.dsebd.org/latest_share_price_scroll_l.php [I want to download data from here]
Thanks in Advance for any support.
It's not problem with Excel.
Website is using iframe-->and denying access to request...
Look for site code by pressing F12. Did it ever worked for you before
The following code will place each trading code, LTP, change and % change on a separate line in the active worksheet.
' open IE, navigate to the website of interest and loop until fully loaded
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.navigate "http://www.dsebd.org/latest_share_price_scroll_l.php"
.Top = 50
.Left = 530
.Height = 400
.Width = 400
Do Until Not IE.Busy And IE.readyState = 4
DoEvents
Loop
End With
If you use F12 to look at the source code, you'll notice that each stock and it's associated data is bracketed by a tagname (in this case "a"). Use this to collect the data for each stock and place the data for all stocks in "Results". Step through "Results" and place each stock on a separate line. Use the replace function to remove a line break so the data appears on 1 line.
Set Results = IE.document.getElementsByTagname("table")(0).getElementsByTagname("a")
x = Results.Length
For y = 0 To x - 1
gg = Results(y).innertext
gg = Replace(gg, Chr(10), "", 1, -1, vbTextCompare)
ActiveCell = gg
ActiveCell.Offset(1,0).Select
Next
Press A1 cell, then data-> http://www.dsebd.org/latest_share_price_scroll_l.php-> click first arrow-> import->ok .....eureka
on cell E1 you will see ur desired thing

embed multiple youtube videos to chromeless player cue

So in the project ive been working on i use the youtube API to add a video to a chromeless player (got custom buttons, everything works no problems).
It loads the youtube id which it gets from the database (Codeigniter, PHP).
But what i would like to see is: instead of loading 1 video, id like to add all the videos i get from the database in the cue of that one player.
So only one screen, first video retrieved from dbase gets played first, when its done second get loaded preferably also looped. Is there any way i can achieve this?
My first guess would be to save the array with youtube id's somewhere and on state change (when the 'video stop'-event gets fired) load the next id from the array. Havent tried this yet because id prefer if the cue gets just gets filled on the init, so it doesnt have to load after a video has been ended. Is This possible?
First, you must use Youtube API version 2 to activate newly statechange function.
This is the code for you:
var video_list = [
'21OH0wlkfbc',
'InZNBcJTmWs',
'iIzqYiRo01E',
'ZYmADPVEqU4'
];
var video_current = 0;
function onYouTubePlayerReady( ) {
var o = document.getElementById( 'ytplayer2_object' );
if( o ) {
o.addEventListener( "onStateChange", "ytplayer_statechange" );
}
}
function ytplayer_statechange( state ) {
// 0 => video ended
if ( state == 0 ) {
video_current++;
video_current %= video_list.length;
ytplayer_loadvideo(video_list[ video_current ]);
}
}

Categories