As anyone any idea on how to update a table in google fusion using Zend framework?
I can get the data:
$url = "https://www.google.com/fusiontables/api/query?sql=SELECT%20name%20FROM%201695591";
$data = $gdata->get($url);
$postcodes = $data->getRawBody();
But have no idea how to update a row ...
I know I have to 'call' this url, but no idea how :
UPDATE table_id
SET column_name = value {, column_name = value }*
WHERE ROWID = row_id
Thank you
Try this class http://barahlo.semero.com/description/Zend_Gdata_Fusion.zip
Example of usage:
$client = Zend_Gdata_ClientLogin::getHttpClient('your_login_here#gmail.com', 'your_pass_here', 'fusiontables');
$base = new Zend_Gdata_Fusion($client);
$sql = "SELECT ROWID FROM 596524 WHERE id = 1;";
$rowdata = $base->query($sql)->get_array();
print_r($rowdata);
$newRowId = $base->insertRow('596524',array(
'id' => time(),
'name' => 'trird row',
'added' => date('n/j/y'),
) );
$base->updateRow(
'596524',
array('name' => 'new first row'),
$rowdata[1][0] //ROWID from insert query
);
Oauth login for Zend_Gdata:
$oauthOptions = array(
'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER,
'version' => '1.0',
'signatureMethod' => 'HMAC-SHA1',
'consumerKey' => $CONSUMER_KEY,
'consumerSecret' => $CONSUMER_SECRET
);
$consumer = new Zend_Oauth_Consumer($oauthOptions);
$token = new Zend_Oauth_Token_Access();
$client = $token->getHttpClient($oauthOptions,null);
$base = new Zend_Gdata_Fusion($client);
// ...
Also, there is official php client library http://code.google.com/p/fusion-tables-client-php/
Related
I'm creating a message on the forum using the rest api:
$point = '/forums/topics';
$endpoint = $url. 'api'. $point. '?key='. $apiKey;
$options = [
'form_params' => [
'forum' => 3,
'title' => $request->title,
'post' => $request->body,
'author' => 1
]
];
$client = new Client();
$request = $client->post($endpoint, $options);
From this API I would need to create the ID to be able to store it in $article->id_topic
but I can't find out how I can go back to the ID of the item created with POST.
I've already done some tests, failing, here are some:
$article->id_topic = $request->id;
and with json_decode
$id_topic = json_decode($request);
$idt = $request->id;
$articoli->id_topic = $idt;
$id_topic = json_decode($request->getBody());
$article->id_topic = $id_topic->id;
$article->save();
I got some example scripts from Facebook App Management to use the Marketing API. When I run the script, I just get this error by curl:
'Unsupported post request. Object with ID \'105101623679981\' does not exist, cannot be loaded due to missing permissions, or does not support this operation.
I already tried to deactivate the Sandbox Mode and go public, tried many different scripts in different languages and also other keys.
Any Ideas?
This is the Script:
<?php
//Add all those Uses and the autoloader
$access_token = '<my_very_long_accessToken';
$ad_account_id = '<my_account_id>'; //<-- This is the Object in the Error Code
$app_secret = '<my_app_secret>';
$page_id = '<my_page_id>';
$app_id = '<my_app_is>';
$api = Api::init($app_id, $app_secret, $access_token);
$api->setLogger(new CurlLogger());
$fields = array(
);
$params = array(
'objective' => 'PAGE_LIKES',
'status' => 'PAUSED',
'buying_type' => 'AUCTION',
'name' => 'My Campaign',
);
$campaign = (new AdAccount($ad_account_id))->createCampaign(
$fields,
$params
);
$campaign_id = $campaign->id;
echo 'campaign_id: ' . $campaign_id . "\n\n";
$fields = array(
);
$params = array(
'status' => 'PAUSED',
'targeting' => array('geo_locations' => array('countries' => array('US'))),
'daily_budget' => '1000',
'billing_event' => 'IMPRESSIONS',
'bid_amount' => '20',
'campaign_id' => $campaign_id,
'optimization_goal' => 'PAGE_LIKES',
'promoted_object' => array('page_id' => $page_id),
'name' => 'My AdSet',
);
//...
Yeah. I got it. It has to be "act_"
So bad. The Script is really crappy. So many Errors. And it's created by facebook!
I am fetching a URL using guzzle POST method . its working and returning the page that I want . but the problem is when I want to get the value of an input element in a form in that page, the crawler returns nothing . I don't know why .
PHP:
<?php
use Symfony\Component\DomCrawler\Crawler;
use Guzzle\Http\Client;
$client = new Client();
$request = $client->get("https://example.com");
$response = $request->send();
$getRequest = $response->getBody();
$cookie = $response->getHeader("Set-Cookie");
$request = $client->post('https://example.com/page_example.php', array(
'Content-Type' => 'application/x-www-form-urlencoded',
'Cookie' => $cookie
), array(
'param1' => 5,
'param2' => 10,
'param3' => 20
));
$response = $request->send();
$pageHTML = $response->getBody();
//fetch orderID
$crawler = new Crawler($pageHTML);
$orderID = $crawler->filter("input[name=orderId]")->attr('value');//there is only one element with this name
echo $orderID; //returns nothing
What should I do ?
You don't have to create a Crawler:
$crawler = $client->post('https://example.com/page_example.php', array(
'Content-Type' => 'application/x-www-form-urlencoded',
'Cookie' => $cookie
), array(
'param1' => 5,
'param2' => 10,
'param3' => 20
));
$orderID = $crawler->filter("input[name=orderId]")->attr('value');
This assumes your POST isn't being redirected, if it is redirected you should add before calling the filter function:
$this->assertTrue($client->getResponse()->isRedirect());
$crawler = $client->followRedirect();
We want to import all our database into one of your lists. We use php. The code is:
$api_key = "dXXXXXXX7eX276XXXXXXXX490";
$list_id = "7XXXb0XXXe";
$Mailchimp = new Mailchimp($api_key);
$Mailchimp_Lists = new Mailchimp_Lists($Mailchimp);
$batch = array();
$batch[] = array('email' => array(
'email' => 'xxxgmail.com',
"euid" => "xxx#gmail.com",
"leid" => "xxx#gmail.com"
),
'merge_vars' => array('FNAME' => 'XXX'));
$subscriber = $Mailchimp_Lists->batchSubscribe($list_id, $batch, false, true, true);
But I get an error
Mailchimp_User_DoesNotExist
Could not find user record with id
I tried many times, removed uuid and leid but no success. What is wrong? Thank you!
The API key used by me was incorrect.
I am trying to get OAuth to work with Google Analytics, but I'm not having any luck. My code looks like this:
require_once('common.inc.php');
$consumerKey = "my.url.net";
$consumerSecret = "nzZ....TX";
$sig_method = "HMAC-SHA1";
$oauth_token = $token ? new OAuthToken($token, $token_secret) : NULL;
$token_endpoint = '/accounts/OAuthGetRequestToken';
$scope = 'https://www.google.com/analytics/feeds/';
$callback_url = "http://my.url.net/pete/oauth/";
$privKey = NULL;
$params = array('scope' => $scope, 'oauth_callback' => $callback_url);
$url = $token_endpoint . '?scope=' . urlencode($scope);
$consumer = new OAuthConsumer($consumerKey, $consumerSecret);
$req = OAuthRequest::from_consumer_and_token($consumer, $oauth_token, 'GET',
$url, $params);
//$req->sign_request($sig_method, $consumer, $oauth_token, NULL);
echo "<PRE>";
print_r($req);
// Fill response
echo json_encode(array(
'html_link' => '',
'base_string' => $req->get_signature_base_string(),
'response' => send_signed_request('GET', $url, array($req->to_header())),
'authorization_header' => $req->to_header()
));
So when this code runs it prints this:
OAuthRequest Object
(
[parameters:OAuthRequest:private] => Array
(
[oauth_version] => 1.0
[oauth_nonce] => 5f....11
[oauth_timestamp] => 1306433873
[oauth_consumer_key] => my.url.net
[scope] => https://www.google.com/analytics/feeds/
[oauth_callback] => http://my.url.net/pete/oauth/
)
[http_method:OAuthRequest:private] => GET
[http_url:OAuthRequest:private] => /accounts/OAuthGetRequestToken?scope=https%3A%2F%2Fwww.google.com%2Fanalytics%2Ffeeds%2F
[base_string] =>
)
When I uncomment this line:
//$req->sign_request($sig_method, $consumer, $oauth_token, NULL);
The script just fails to load showing Server Error. What am I doing wrong? Any advice would help, thanks!
Thanks for your comment Mark, this was actually because my "$sig_method" variable was actually just a string containing "HMAC..." when it actually needed to be an object called this:
$sig_method = new OAuthSignatureMethod_HMAC_SHA1();
Hope this helps someone in the future!