|
|||||||
| PHP Discussions about the widely-used general-purpose scripting language PHP that is especially suited for Web development and can be embedded into HTML. |
| Post Reply |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi, I'm confused by what I'm sure is a simple task but I can't see the wood for the trees...
I'm successfully placing bets using the following code: Code:
$price = 1000; $size = 2; $bets = array(); $bets1['PlaceBets'] = array( 'asianLineId' => 0, 'betType' => 'B', 'betCategoryype' => 'E', 'betPersistenceType' => 'NONE', 'marketId' => $eventID, 'price' => $price, 'selectionId' => $selectionID, 'size' => $size, 'bspLiability' => 0 ); $bets = array($bets1['PlaceBets']); $placeBetsResp = $betfairlibrary->betfair_exchange_api->betfair_place_bets($sessionToken, $bets); I want to be able to check that the betId was placed successfully by checking to see that it does not equal zero. If it is, I want to retrieve the error information contained within the response. I presumed I could simple point to the corresponding array element with the following code, but when I do I receive an error. Code:
$confirmedbetId = $placeBetsResp['Result']['betResults']['PlaceBetsResult'][0]['betId']; Quote:
|
|
#2
|
|||
|
|||
|
Wongo,
check here: https://docs.developer.betfair.com/b...MC.00008311-MC If the bet is placed successfully then "success=true" else "False" For a more detailed response check: "resultCode" of type "PlaceBetsResultEnum" Error messages range from "OK" to "What went wrong" Hope this helps |
|
#3
|
|||
|
|||
|
Thanks for the reply BigSprout
I've read the documentation you pointed to. My problem doesn't lie with what to check. It is my lack of knowledge on the php programming side. How do I reference any of the individual elements of the array that is returned? If I use the php print_r() function I get the following (where the sessionToken and the betId fields have been edited by me): Quote:
Code:
$confirmedbetId = $placeBetsResp['Result']['betResults']['PlaceBetsResult'][0]['betId']; Quote:
Thanks for you help. |
|
#5
|
|||
|
|||
|
I'm new to PHP and am having trouble accessing the contents of the responses returned from the api functions.
For example: $eventResponse = $betfair->betfair_global_api->betfair_get_all_event_types($loginResponseError[1]); $eventName = $eventResponse->Result->eventTypeItems[0]->name; This gives this error when run: Fatal error: Cannot use object of type stdClass as array How would I access the name of the first event? Any suggestions? |
| Post Reply |
| Thread Tools | |
| Display Modes | |
|
|