Google Calendar API causing HTTP Error 500 - php

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();

Related

Correct way to pass values to Cloud function

I have tried various approaches but cannot seem to get this right.
When I pass data to the Cloud function I have trouble retrieving them in Cloud Code.
Example:
ParseCloud::run('addAlarm', ['subject' => $subject]);
Will pass the following request to the function in Cloud Code:
{"body":"{\"subject\":\"Re: Alarm\"}","params":{"subject":"Re: Alarm"},"installationId":"","user":null,"master":false}
I can read request.body to get:
{"subject":"Re: Alarm"}
But reading request.body.subject yields undefined
I was unable to find any examples where arguments is passed to the Cloud function in PHP, so am currently running on trial and error.
"body":"{\"subject\":\"Re: Alarm\"}"
In your JSON the key body holds a String which looks like JSON. You can either use JSON.parse(request.body) in your JavaScript or use a PHP method that sends the body as an object.

Magento api cart_coupon.add does not work

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.

Eventbrite retrieve event id from event_new PHP API method

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/

cpanel XML API 404 error

Had a look at quite a few posts on stack and the cpanel forum but still cant seem to find a solution.
Im trying to retreive information via an api call but it just always seems to fail. I know its to do with the url 404'ing but not sure how to fix.
I am using the the XMl API class:
https://github.com/CpanelInc/xmlapi-php/
The code I have is:
$this->load->library('xmlapi');
$xmlapi = new xmlapi(XMLAPI_HOST);
$xmlapi->password_auth(CPANEL_USER, CPANEL_PASSWORD);
$xmlapi->set_debug(1);
echo '<pre>';
print_r($xmlapi->accountsummary(CPANEL_USER));
echo '</pre>';
The above outputs the xml array. In the error_notice it says:
HTTP error 404, The requested page was not found.
Thats fine. So I echo out the url it uses which 404's:
http://mysite.co.uk:2082/xml-api/accountsummary
The cpanel docs are a little awkward to navigate but just cant find anything on the actual url structure, besides its the class that compiles the url. ive tried adding www, tried an ip etc but no idea why its erroring.
Also if it helps im accessing a normal cpanel account, not a WHM admin and its through http.
Thanks for reading, any help guidance on getting it working would be appreciated.
The issue you are experiencing is that you are attempting to use the accountsummary function from cPanel ports (2082/2083). The accountsummary function is limited to the administrator accounts since this function is designed to provide administrative api level access for pulling account information from any user on the server.
To access the accountsummary api, you will need to call the accountsummary api from the following url:
https://$SERVER_IP:2087/xml-api/accountsummary?user=$USERNAME
You will need to replace $SERVER_IP and $USERNAME with their respective values.
http://docs.cpanel.net/twiki/bin/view/SoftwareDevelopmentKit/ShowAccountInformation

Call to undefined method in facebook call to publishUserAction

I'm getting the following using the PHP client on my server (connecting via FBML). I've included the appropriate php files (facebook etc..)
Fatal error:
Call to undefined method FacebookRestClient::feed_publishUserAction()
in ..../index.php on line 50
I'm trying to use the example given.
Any ideas?
You might want to take a quick browse/grep through your Facebook API files (facebookapi_php5_restlib.php) and make sure that the feed_publishUserAction() method exists. Perhaps you're using an older version of the API library?
OMG I found the answer
Because the facebookapi_php5_restlib.php that facebook.com provided you is a piece of outdated shit
i.e. you won't be able to find the word feed_publishUserAction in the facebookapi_php5_restlib.php file
HOWEVER, the official facebook smiley demo from this facebook wiki page , contained a more completed facebookapi_php5_restlib.php , along with the feed_publishUserAction function
Which finger would you like to show to the facebook developer staffs?

Categories