I am creating Android app that allows user to add product into his shopping cart and places order.
I am using XMLRPC for this purpose.
Following steps I have done
1.cart.create
2.cart_customer.set
3.cart_customer.addresses
4.cart_shipping.list
5.cart_shipping.method
6.cart_product.add
7.cart_payment.list
8.cart_payment.method
All code works fine till cart_payment.method , but when I call cart_coupon.add api I get exception
org.xmlpull.v1.XmlPullParserException: expected: START_TAG {null}methodResponse
(position:START_TAG (empty) <br>#1:7 in java.io.InputStreamReader#4151b450)
at org.kxml2.io.KXmlParser.require(KXmlParser.java:2046)
My code is:
client = new XMLRPCClient(url);
object = client.callEx("call", new Object[]{sessionId,
"cart_coupon.add",new Object[]{shoppingCardId,couponcode}});
where url is valid magento host url,shoppingCardId is CardId that I get from server.
Exception is at class XMLRPCClient, at line
pullParser.require(XmlPullParser.START_TAG, null, Tag.METHOD_RESPONSE);
I think server replies with blank string and parser doesn't find start tag.
If I call same api through php script, cart_coupon.add and cart.order work fine and I get order id in response and
at server side in sales->orders , I can see order has been placed successfully.
But when I follow same procedure from Android I get Exception described above.
What should I do?
I also got same problem. I bypassed XMLRPC for last call and written php script to place order.
Related
Using PHP I need to get a list of company webex meetings and show them on web page
I tried the code on this page: https://developer.cisco.com/site/webex-developer/develop-test/xml-api/sample-code/
But that failed.
<serv:header>
<serv:response>
<serv:result>FAILURE</serv:result>
<serv:reason>Failed to get SiteUrl</serv:reason>
<serv:gsbStatus>PRIMARY</serv:gsbStatus>
<serv:exceptionID>010000</serv:exceptionID>
</serv:response>
</serv:header>
<serv:body>
Error message was that it could not find the SiteURL. The siteurl I was using is companyname.webex.com - when I put that url into browser, it goes to our webex page, so it seems to be correct.
I found this: http://joshuamcginnis.com/webex/ and tried it (using real credentials), but it gives a 500 error and I have no access to logs.
Both of these examples are very old and I am struggling to find up-to-date examples.
If I put https://company.webex.com/WBXService/XMLService into browser, I get a success message
Can anyone suggest how to do this in either PHP or javascript
According to the PHP example in the link, you must be using something like:
<securityContext>
<webExID>YourCiscoUsername#example.com</webExID>
<password>YourCiscoPassword</password>
<siteID>243585</siteID>
<partnerID>g0webx!</partnerID>
</securityContext>
Try using the "siteName" instead of "siteID", like the following:
<securityContext>
<webExID>YourCiscoUsername#example.com</webExID>
<password>YourCiscoPassword</password>
<siteName>go</siteName>
<partnerID>g0webx!</partnerID>
</securityContext>
You can use siteID or siteName indistinctly, but looks like that siteID isn't working for that demo site right now. Their Java and .Net examples are using siteName.
Now, you have to use "go" in siteName if you are making the request to https://go.webex.com/WBXService/XMLService
But you must use "apidemoeu" if you are making the request to
https://apidemoeu.webex.com/WBXService/XMLService
They both appear to be demo sites.
And effectively "Failed to get SiteUrl" is the error returned if the value passed in either siteName or siteID doesn't correspond to an existing site.
The one page checkout for my store doesn't complete. On the final step (order review), I get this error as a return from the Ajax call to checkout/onepage/saveOrder:
Server was unable to read request. ---> There is an error in the XML document. ---> Input string was not in a correct format.{"success":true,"error":false}
After logging every variable and array I could find in the saveOrderAction method of OnepageController.php, it looks like the redirectUrl from this line is returning nothing:
$redirectUrl = $this->getOnepage()->getCheckout()->getRedirectUrl();
I haven't found anyone else having this exact problem, and I have a feeling this is being caused by some admin setting that I missed while setting my store up. The production site works fine and I've copied every file onto my local server. Any ideas?
I was trying to parse the rss of the tag PHP, from http://stackoverflow.com and tried to use something other than DOM Model, So I looked into SimpleXML. THis is my code:
<?php
error_reporting(-1);
$xml = file_get_contents('https://stackoverflow.com/feeds/tag/php');
$loaded = simplexml_load_string($xml) or die("There is a problem");
$str1 = $loaded["entry"]["entry"][0]->title;
echo $str1;
?>
But nothing is displayed on the screen, and also no error is displayed!
The sample data from https://stackoverflow.com/feeds/tag/php can be found at
http://gourabt2.cloudapp.net/sample-data/sample_data.xml
Any Help would be very much appreciated! Thanks! Cheers!
You use array-access in SimpleXML to access attributes so:
$loaded["entry"]
returns the attribute named "entry" from the document element.
use arrow-access to get the element named "entry" instead:
$loaded->entry
this returns the element named "entry".
Additionally take care with namespaces. Parsing a feed with SimpleXML has been outlined already in existing Q&A material, please relate to it.
Try this out.
<?php
$xml = file_get_contents('http://stackoverflow.com/feeds/tag/php');
$loaded = simplexml_load_string($xml) or die("There is a problem");
foreach($loaded->entry as $post) {
echo $post->title . "\n";
}
Output:
join 2 tables - group by id order by date price asc
using php variable in an sql query
Clear browser cache memory by php code
There is a error in parsing the rss from stackoverflow.com. using SimpleXML in PHP
Modify Laravel Validation message response
chained dropdown from database
Php database handling
How to load model with Codeigniter Webservice - Nusoap Server?
multiple report download php adwords api
Unable to confirm Amazon SNS subscription for SES bounces
Comparing if values exist in database
Better way to CURL to WCF
PHP SaaS Facebook app: Host Page Tab ID and User ID
PHP and Mysql - running over PDOStatement
How to change form textbox value in Zend form annotation?
connect Android with PHP, MySQL , unfortunately app has stopped in android emulator
Auto increment a SESSION key ID
Call PHP function in a class from a HTML form
PHP SQL Preventing Duplicate User names: Catching Exception vs Select Query
I am only able to grab the first group of text in between the tr need helping fixing my code
How to run an external program in php
How to connect to php in android using an async task?
PHP Return HTML (Laravel / Lumen Framework)
prestashop smarty if statement
Cakephp OR condition Implementation
Progress bar HTML5/PHP
preg_match file url from jwplayer
Does Cloudflare Cache HTML5 Video Embedded on PHP Page?
how to INSERT INTO JOIN
PHP web service returns "403 forbidden" error
That's because you have the wrong path. Here is the correction.
(string)$loaded->entry->title;
I need some help in retrieving the event id from the event_new PHP API method. I can see that the URL method works well by returning an XML file containing the new ID, however the response I get from the PHP API method is simply 'NULL'.
The documentation says that both the XML and URL methods return the new event ID, can anyone offer some assistance on what I need to do?
Cheers
Paul
I'm not able to reproduce your error. Do you have any sample code to share?
What PHP version are you running?
This test works fine for me:
//PHP API Client Lib is available here: https://github.com/ryanjarvinen/eventbrite.php
include "Eventbrite.php";
//Authorization tokens are outlined here:
// http://developer.eventbrite.com/doc/authorization/
$eb = new Eventbrite(array('app_key'=>'YOUR_APPLICATION_KEY','user_key'=>'YOUR_USER_KEY'));
try{
//Docs on how to use the API's event_new method are located here:
// http://developer.eventbrite.com/doc/events/event_new/
$response = $eb->event_new(array('title'=>'test event_new','start_date'=>'2012-12-12 12:00:00','end_date'=>'2012-12-12 12:12:12'));
print "The new event_id is: {$response->process->id}";
}catch( Exception $e){
var_dump($e);
}
There are a few more PHP-specific usage notes available on github.
Most of the general information about authentication tokens, as well as specifics on input and output parameters per API method, should be available on http://developer.eventbrite.com/
I'm using the new Google Calendar API v3. I'm trying to obtain the users calendar list using the PHP library. If I make the request directly using CURL then it works fine, but for some reason when I try and use the PHP library it fails and throws a 500 error.
Here's the (abbreviated) code:
$this->calendarAPI = new apiCalendarService($this->client);
$calendar_list = $this->calendarAPI->calendarList->list();
If I var_dump the contents of $this->calendarAPI->calendarList then I get an object as I would expect. It's only when I call the list method that everything goes wrong.
Can anyone help or am I going to have to write my own library and interact with the API protocol directly?
Ok, so it turns out this is a mistake in the docs. Instead of calling a method called list() you have to call listCalendarList() so the second line should be:
$calendar_list = $this->calendarAPI->calendarList->listCalendarList();