Eventbrite retrieve event id from event_new PHP API method - php

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/

Related

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.

Updating documents with the help of cas in couchbase 2.0 server using PHP API

I am trying to update a document in Couchbase 2.0 server using PHP API (php-ext-couchbase).
http://www.couchbase.com/docs/couchbase-sdk-php-1.1/api-reference-summary.html
The document is similar to facebook POSTS with comments and likes associated with it.
To be more specific.
-Load the doc.
-Modify it
-Store the modified doc if it has not been accessed by any other person.
Basic operations that would be required to accomplish this will be
# Get a document by key
doc = get(key)
# Modify a document when no one has modified it since my last read
casVersion = doc.getCas()
cas(key, casVersion, changedDoc)
I just want to know how i can accomplish this in PHP.
especially how to get the casVersion or the revision_id of the document and then further carry out the update process so that changes made by simultaneous updates on same document are not lost.
No worries I found it,
The code is
$bucket='yourbucketname';
$cb=new Couchbase("127.0.0.1:8091","root","password",$bucket);
$old_doc=null;
$cb->getDelayed($obj_id, true,
function($cb, $data) use (&$old_doc) { $old_doc = $data; });
$casKey=$old_doc['cas'];
Use getDelayed method, and callback function to get the array having (key,value,caskey)
I hope the couchbase documentation would be more clear in future with usages examples.

UserVoice API Call in PHP

Can anyone please give a Simple Example of UserVoice API call in PHP that retrieve something (could be anything like article etc etc) because i am unable to find any Example that is doing something like that...!!
I have seen at many Places even i searched a lot before using it that is there any example for PHP to retrieve the data using UserVoice API but unable to find so after lots of things i found solution myself here is an example i am posting but few things needed:
Make Sure you have the API Key which you can get by going in Settings>Channels
Apply for the API Client in the API section clicking "Add API client" button fill the form and it will generate a API Key and some other useful information
Now Open your PHP File Lets say you want to get all the articles on your Website using API then you can use following code:
$r = new HttpRequest('https://YOUR_DOMAIN_NAME/api/v1/articles.json', HttpRequest::METH_GET);
$r->addQueryData(array('client' => 'INSERT_YOUR_API_KEY_HERE'));
try {
$r->send();
if ($r->getResponseCode() == 200) {
$obj=json_decode($r->getResponseBody());
print_r($obj);
}
}
catch (HttpException $ex) {
echo $ex;
}

Pubsubhubbub subscriber callback implementation in PHP

I am trying to use the PSHB protocol to be notified of my Google alerts. I am using the code found here. However, it is not clear to me how to implement the callback (or endpoint).
Can someone provide a trivial example that shows how I can access the data that has been POSTed to my endpoint?
A (slightly modified) snippet of the google code follows below:
<?php
// simple example for the PHP pubsubhubbub Subscriber
// as defined at http://code.google.com/p/pubsubhubbub/
// written by Josh Fraser | joshfraser.com | josh#eventvue.com
// Released under Apache License 2.0
include("subscriber.php");
$hub_url = "http://pubsubhubbub.appspot.com";
$callback_url = "http://www.example.com/mycallback.php"; // <- how to implement this ?
[[Edit]]
I have added some pseudocode below, to help clarify the question further ...
// Implementation of mycallback.php
<?php
$pubsub_post_vars = $_POST[WHAT_NAME_AM_I_LOOKING_FOR]; //what's the name of the POST var?
// How do I get to the 'good stuff?
$feed_id = $pubsub_post_vars[SOME_VARIABLE]
$feed_title = $pubsub_post_vars[ANOTHER_VARIABLE]
$contents = $pubsub_post_vars[YET_ANOTHER_VARIABLE]
$author = $pubsub_post_vars[YET_ANOTHER_VARIABLE_1]
$perma_link = $pubsub_post_vars[YET_ANOTHER_VARIABLE_2]
$pub_date = $pubsub_post_vars[YET_ANOTHER_VARIABLE_3]
?>
I realize that approach (above) may be complete wrong, as I suspect that it is an RSS/ATOM document that is POSTed. However, some skeleton code like the one above should be enough to get me started, so that I can extract things like the feed id, title and published content ... etc.
Well, the way to implement it really depends on what you want to achieve with it.
But generally, there are 2 things your callback needs to handle:
Verification of intent
Handling of notifications
For the Verification of Intent, your callback needs to echo the hub.challenge parameter, if you really want the subscription for that specific feed.
For the handling of the notification, your callback probably needs to check the validity (signature), if you'v used a secret when susbribing and, later it needs to read and save the content of the body.
[UPDATE] Beware, the notification will not be included in any POST variable, it will be the full body itself (Accessible thru $request_body = #file_get_contents('php://input');). POST vars are usually parsed by PHP from the body. In this context, you do want to access the raw body. You will then be able to extract all the vars you're looking from the XML (RSS or Atom) posted to you.

Google Calendar API causing HTTP Error 500

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

Categories