I'm trying to get keyword ideas from AdWords API by page URL, but so far I'm only able to get keywords list by another keyword.
What I want to do is possible via web interface, but as for API, docs say that the only available value for ideaType property is KEYWORD.
Are there any alternatives for ideaType, maybe via creating a new campaign, or something else?
I'm using PHP.
I'm new to Google AdWords. Help appreciated!
In fact, I misunderstood the goal of ideaType property. This property is not the input search parameters type.
For getting keyword ideas by URL you can use RelatedToUrlSearchParameter class.
In my case code looks like following (the most relevant part):
$selector = new TargetingIdeaSelector();
$selector->requestType = 'IDEAS';
$selector->ideaType = 'KEYWORD';
$selector->requestedAttributeTypes = array('KEYWORD_TEXT', 'SEARCH_VOLUME', 'CATEGORY_PRODUCTS_AND_SERVICES');
$relatedToUrlSearchParameter = new RelatedToUrlSearchParameter();
$url = $_GET['url'];
$relatedToUrlSearchParameter->urls = array($url);
$selector->searchParameters[] = $relatedToUrlSearchParameter;
Related
As I couldn't find anything in the documentation I might have a general understanding issue. But what I want to achieve is getting the ID of the current Contact browsing the Site. To get user details I always have to know the ID, like documented here: https://developer.mautic.org/#contacts
$api = new MauticApi();
$contactApi = $api->newApi("contacts", $auth, $settings['baseUrl']);
$contact = $contactApi->get(3);
Is there a way to the ID of the current Contact? I want to play highly customized content on the website and an entry point to get user details.
It's a REST API, so you should get a response in any case. What's the content of the response (eg. what contains $contact)? What's the HTTP code of the response? Error messages?
However... I'm not familiar with this particular API, but the principles are always the same
https://developer.mautic.org/?php#list-contacts
Without any query parameters it should give the full list of contacts. Each of the contact records should come with an ID for the details:
https://developer.mautic.org/?php#get-contact
As said, I'm not familiar with the API, so it could be that you get a contact list only from a higher entity, like a Company or so.
I can recommend Postman (https://www.postman.com/), a neat tool to make REST API requests while having full control over all the details.
Assuming that you're trying to get the details of the current logged in user.
You can use themautic.helper.user helper to do that as shown below:
<?php
$user = $this->get('mautic.helper.user')->getUser();
$firstName = $user->getFirstname();
$lastName = $user->getLastname();
$email = $user->getEmail();
$profile = $user->getProfile();
$role = $user->getRole()->getName();
if ($role->isAdmin()) {
// do something
}
Ref: https://developer.mautic.org/#services44
In order to do what you want here I do not think you actually need the API to get the user id. Mautic has dynamic content and as long as the user has a cookie dropped on his browser you can use Dynamic Content to say "Hi {contactfield=firstname}, welcome back.
You can actually call any custom field into the dynamic content slot.
Check out dynamic content which is found under the Components section in the left menu
I'm actually building a PHP bot that reads the youtube live streaming chat, and store in a Database the message that contains a specific keyword wrote by the users during the livestream. All the logic is in place, what is missing is the feedback on chat when the bot is "triggered".
I looked everywhere but seams the PHP documentation is missing, if you look inside the PHP Classes there is the public function insert, but there is no example at all on how to use it?
Someone know how to use it?
Should be something "simple" like: $result = $youtube->liveChatMessages->Insert($args); but I can't figure out on what args looks like.
HERE the only reference about the Insert method
Thanks to all for any suggestion on how to use it!
17/06/2018 edit Working Example
$liveChatMessage = new Google_Service_YouTube_LiveChatMessage();
$liveChatSnippet = new Google_Service_YouTube_LiveChatMessageSnippet();
$liveChatSnippet->setLiveChatId($liveChatID);
$liveChatSnippet->setType("textMessageEvent");
$messageDetails = new Google_Service_YouTube_LiveChatTextMessageDetails();
$messageDetails->setMessageText("Message to type in chat");
$liveChatSnippet->setTextMessageDetails($messageDetails);
$liveChatMessage->setSnippet($liveChatSnippet);
$videoCommentInsertResponse = $youtube->liveChatMessages->insert('snippet', $liveChatMessage);
I have an observer event that is capturing customer details anytime they are updated. At this point it posts that information to a var log.
I would like to get it to post to a SOAP API url.
SOAP API URL
at this point I am trying to be pointed in the right direction of how to do this, I believe I need to write the information into an XML that matches the API.
I only have 6 fields that need to be filled so I don't think it will be to hard.
$fon = $billingaddress->getTelephone();
$street1 = $billingaddress->getStreet(1);
$street2 = $billingaddress->getStreet(2);
$city = $billingaddress->getCity();
$region = $billingaddress->getRegion();
$postcode = $billingaddress->getPostcode();
The phone number doubles as the customer #
Can somebody help me with the code to write the XML?
This chunk will go inside your body tag, as shown in the examples HERE. For the XML, it is pretty straightforward, and you can do it as one $request variable instead of assigning several:
<?php
$request = '<UpdateCustomer xmlns="http://www.dpro.com/DPAPIServices">'.
'<aRequest>'.
// '<Username>'..'</Username>'.
// '<Password>'..'</Password>'.
'<CustomerNumber>'.$billingaddress->getTelephone();.'</CustomerNumber>'.
'<CustomerName>'.$billingAddress->getFirstname().' '.$billingAddress->getLastname().'</CustomerName>'.
'<CustomerAddress1>'.$billingaddress->getStreet(1).'</CustomerAddress1>'.
'<CustomerAddress2>'.$billingaddress->getStreet(2).'</CustomerAddress2>'.
'<CustomerCity>'.$billingaddress->getCity().'</CustomerCity>'.
'<CustomerState>'.$billingaddress->getRegion().'</CustomerState>'.
'<CustomerZip>'.$billingaddress->getPostcode().'</CustomerZip>'.
'</aRequest>'.
'</UpdateCustomer>';
?>
NOTE:
I commented out the Username and Password because they weren't included in your example, and I am unsure whether they are your API user's credentials or related to the Customer.
You shouldn't need to write any XML when working with a SOAP API that already exists. Use the built-in SoapClient.
Have a look at the answers to this question if you need help with that: How to make a PHP SOAP call using the SoapClient class
I'm trying to write a simple app for my website and struggling with 1 point.
A Facebook Page has;
$pageID = 'dorimedia';
What does a website have that is equal? I want to get the value to show how many times an external website has been 'liked'.
Nothing.
You could use the domain name, or domain name + path as in full route, but no short ID per se.
http://www.google.com could be the id
http://www.google.com/route could also be an id
If you need something shorter, and not necessarily readable by you, you could hash it or apply some encrypting algorithm to the full url to get a shorter id, try looking into the md5,sha1 or hash methods (assuming your using php)
UPDATE
If what you need is how many facebook like's a website has, there is an API for this directly from google that goes like this:
http://api.facebook.com/restserver.php?method=links.getStats&urls=www.google.com
Which results in an xml response that includes, comments, likes and other interesting information. Google for instance has the following response:
<links_getStats_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
<link_stat>
<url>www.google.com</url>
<normalized_url>http://www.google.com/</normalized_url>
<share_count>2095550</share_count>
<like_count>795778</like_count>
<comment_count>705595</comment_count>
<total_count>3596923</total_count>
<click_count>265614</click_count>
<comments_fbid>381702034999</comments_fbid>
<commentsbox_count>307</commentsbox_count>
</link_stat>
</links_getStats_response>
Then its a matter of extracting the information from that XML, easily enough like this:
$url = "http://api.facebook.com/restserver.php?method=links.getStats&urls=".urlencode($source_url);
$xml = file_get_contents($url);
$xml = simplexml_load_string($xml);
$shares = $xml->link_stat->share_count;
$likes = $xml->link_stat->like_count;
$comments = $xml->link_stat->comment_count;
$total = $xml->link_stat->total_count;
$max = max($shares,$likes,$comments);
Click here for the Source
In Short, I am pulling the feed from my blogger using the Zend API in PHP. I need to get the URL that will link to that post in blogger. What is the order of functions I need to call to get that URL.
Right now I am pulling the data using:
$query = new Zend_Gdata_Query('http://www.blogger.com/feeds/MYID/posts/default');
$query->setParam('max-results', "1");
$feed = $gdClient->getFeed($query);
$newestPost = $feed->entry[0];
I can not for the life of me figure out where I have to go from here to get the URL. I can successfully get the Post title using: $newestPost->getTitle() and I can get the body by using $newestPost->getContent()->getText(). I have tried a lot of function calls, even ones in the documentation and most of them error out. I have printed out the entire object to look through it and I can find the data I want (so I know it is there) but the object is too complex to be able to just look at and see what I have to do to get to that data.
If anyone can help me or at least point me to a good explanation of how that Object is organized and how to get to each sub object within it, that would be greatly appreciated.
EDIT: Never mind I figured it out.
You are almost there, really all you need to do is once you have your feed entry is access the link element inside. I like pretty URLs so I went with the alternate rather than the self entry in the atom feed.
$link = $entry->link[4]->href;
where $entry is the entry that you are setting from the feed.
The solution is:
$query = new Zend_Gdata_Query('http://www.blogger.com/feeds/MyID/posts/default');
$query->setParam('max-results', "1");
$feed = $gdClient->getFeed($query);
$newestPost = $feed->entry[0];
$body = $newestPost->getContent()->getText();
$body now contains the post contents of the latest post (or entry[0]) from the feed. This is just the contents of the body of the post, not the title or any other data or formatting.