Recommend this page to a friend! |
PHP OAuth Library | > | PHP OAuth Library package blog | > | How to Implement a PH... | > | All threads | > | Yahoo Gemini Custom Reporting | > | (Un) Subscribe thread alerts |
|
![]() Hello.
First of all great Library! I'm using the mysqli_oauth_client class for multiple APIs and it works fantastically!!! However my latest attempt to use it with Yahoo Gemini isn't going so well. Your sample yahoo request works fine, so I know I have correct credentials etc... However, when I try to alter it to make a requests against the Gemini end point I get errors. Here is the Yahoo documentation the example request I'm trying to make. developer.yahoo.com/gemini/guide/cu ...I've tried various permutations of the below code, changing values of $body, RequestContentType etc... but nothing works. The most common error I get is: Please provide valid credentials. OAuth oauth_problem="unable_to_determine_oauth_type", realm="yahooapis.com" I think I'm using your library incorrectly. Can you post example code of how I can retrieve data from Yahoo Gemini custom reporting? Below is my current attempt. Also... do you accept payment? I would like contribute, if I can, since your library is so useful to us. Thanks. $client = new mysqli_oauth_client_class; $client->debug = true; $client->offline = true; $client->debug_http = true; $client->server = 'Yahoo'; $client->client_id = 'xxxxx'; $client->client_secret = 'xxxx'; $client->database = array( 'host'=> DB_HOST, 'user'=> DB_USER, 'password'=> DB_PASS, 'name'=> DB_NAME ); $client->user = '11111'; $success = $client->Initialize(); $body = '{ "cube": "performance_stats", "fields": [ { "field": "Day" }, { "field": "Impressions" }], "filters": [ {"field":"Advertiser ID","operator":"=","value": XXXXX }, {"field":"Day", "operator": "between", "from": "2015-10-10", "to": "2015-10-10" } ] }'; // Get Campaign Data $success = $client->CallAPI( 'https://api.admanager.yahoo.com/v1/rest/reports/custom', 'POST', array(), array('FailOnAccessError'=>true,'RequestBody'=>$body,'RequestContentType'=>'text/json'), $ads);
![]() Looks correct. Can you enable debug, get the PHP error log starting from the CallAPI and post it here so I can see what is going on?
![]() Thank you for your quick reply. Below is the entire output with both debug and debug_http set to true.
PHP Notice: Undefined index: port in /lamp/public_html/signup/vendor/phpclasses/oauth-api/mysqli_oauth_client.php on line 25 PHP Notice: Undefined index: socket in /lamp/public_html/signup/vendor/phpclasses/oauth-api/mysqli_oauth_client.php on line 25 OAuth client: Getting the OAuth session for user 11111 OAuth client: Query: SELECT id, session, state, access_token, access_token_secret, expiry, authorized, type, server, creation, refresh_token, access_token_response FROM oauth_session WHERE user=? AND server=? OAuth client: Query parameter type: i value: 11111 OAuth client: Query parameter type: s value: Yahoo OAuth client: The OAuth access token A=lNjTXujE71pry3E.BVvCaUvbqOhNn5izZsO0BH5fErHgHPRHFN2I8y5JWmqluhP_QEu3awGSMTQGrd4FSq8A1tAjsOPwTrFRuWvgUUm3Hi5CH6IsXYUonWiuXooPXEzM4auo8ZPoTp0k9sCOjLGWcku8ksWtBbjJwwOmrHgz8syToJkO0yZYF8NVkAnXIm0NA2gUIA06CiB7pJERCvbNFQHlVEroqG5NIPfrhWymI434Nep.5EgTj44t3A3mP9av4EjwXIykNYF5GpGp00G6Vf2acOolOU0sTfIuPz_2ysPpJ4d4VKofPL3z7ISW9tmSE.eBwJOvNm5qPiGuT3auIXLycKWYjhxHozurmy9FZCsmafweUHVpS0Xdpdnd.C84eD26OVBywDddA.llYtJr0m04n0qmqoua_KPEbXyX07hwyDQ5TB4vB2OltaVSZiASAohoTdMVGWuatunRvtHUgSlqXwRFuxNYOkXa1Bq7WbJKkg7cg_1fnxXtYDvTPg.7YAG8tNWKRVYxKepKp5SR4HDAy3ED0X6I6VC8SV1sUS5qJRddX3cDMnAKQc2rSQjxL8M.PyydGnZHKK_WTzCGGl6RsCB.UiZzVCWihLbV4mU8v7usciZ1hAI38pNQ0SRPsupanezAGQd59G4CHqlVB4IWCFlxMs2TMLE9H9FvyOgZkO_wAIRLGLxvg6eL1tXPT16SMv7vl8k47UtRD7e_2hYXw_3HE4iaV42Ra7LfbcXW6F1O8YtxulowMekWOangXUDAVpxb1hoh2fCtLiaF9xSOLNeSJCbnJ6H3E0jj9Wzy1NAcRlUdUyTnmkk.CfMEmkg- is valid OAuth client: The OAuth access token expires on 2015-10-16 05:17:24 OAuth client: The OAuth access token secret is 5b862a1f0ea9c7d7c344b68365f3a8305d7dca81 OAuth client: Accessing the API call at https://api.admanager.yahoo.com/v1/rest/reports/custom Connecting to api.admanager.yahoo.com Resolving HTTP server domain "api.admanager.yahoo.com"... Connecting to HTTP server IP 67.195.33.15 port 443... Connected to api.admanager.yahoo.com C POST /v1/rest/reports/custom HTTP/1.1 C Host: api.admanager.yahoo.com C User-Agent: PHP-OAuth-API (http://www.phpclasses.org/oauth-api $Revision: 1.141 $) C Content-Type: application/json C Accept: */* C Connection: Keep-Alive C Content-Length: 270 C C { "cube": "performance_stats", "fields": [ { "field": "Campaign ID" } ], "filters": [ { "field": "Advertiser ID", "operator": "=", "value": 1092987 }, { "field": "Day", "operator": "between", "from": "2015-10-10", "to": "2015-10-12" } ] } S HTTP/1.1 401 Authorization Required S Date: Fri, 16 Oct 2015 04:54:18 GMT S Server: Apache S WWW-Authenticate: OAuth oauth_problem="unable_to_determine_oauth_type", realm="yahooapis.com" S Content-Length: 285 S Connection: close S Content-Type: application/xml S X-Pad: avoid browser bug S S <?xml version='1.0' encoding='UTF-8'?> <yahoo:error xmlns:yahoo='http://yahooapis.com/v1/base.rng' xml:lang='en-US'> <yahoo:description>Please provide valid credentials. OAuth oauth_problem="unable_to_determine_oauth_type", realm="yahooapis.com"</yahoo:description> </yahoo:error> Disconnected from api.admanager.yahoo.com OAuth client: Could not retrieve the OAuth access token. Error: it was not possible to access the API call: it was returned an unexpected response status 401 Response: <?xml version='1.0' encoding='UTF-8'?> <yahoo:error xmlns:yahoo='http://yahooapis.com/v1/base.rng' xml:lang='en-US'> <yahoo:description>Please provide valid credentials. OAuth oauth_problem="unable_to_determine_oauth_type", realm="yahooapis.com"</yahoo:description> </yahoo:error>
![]() There seems to be a bug in the class that does not sign OAuth 1.0a requests when the method is POST but it has a custom body.
I am working on another feature and will get back to that bug soon. Please be patient.
![]() ok. Thank you for looking into this.
|
info at phpclasses dot org
.