I'm using PHRets and trying to return some search results. Below is the code, which is very basic and should work:
include('../include/common.php');
include('../classes/phrets.php');
$rets = new phRETS();
$connect = $rets->connect(RETS_LOGIN_URL, RETS_USERNAME, RETS_PASSWORD);
if($connect){
$search = $rets->SearchQuery('PROPERTY', 'RES', '((COUNTY=Dallas))', array('LIMIT'=>20));
print_r($rets->Error());
echo $rets->TotalRecordsFound($search);
$rets->Disconnect();
}else{
$error = $rets->Error();
print_r($error);
}
When I run the page, I receive the following error:
Array ( [type] => rets [code] => 20203 [text] => The request limit is too large for a GET. Please use the POST method to submit your search. ) 0
I don't see a parameter to force PHRets to send the request as a POST. Will this require a hack of the class, or am I missing something?
Thanks
EDIT: I just heard back from the developer. It's not supported at this time. Perhaps a less-busier person should clone it and work on that.. :) Anyway, if anyone has already has modified the code to make this work, let me know, please.
Get the latest phRETS version which supports POST method from here and replace with your old phrets.php.
then you need to add an extra line to the script
$rets->SetParam('use_post_method', true);
Note: By default it will be GET method.
I've published an updated version supporting POST searches available at https://github.com/nathanklick/PHRETS or via composer by adding "nathanklick/phrets": "1.0.2" to your composer.json file.
Related
I just found out that Facebook updated their graph api and now require an access token to retrieve like counts for a page to be displayed on an external website. I went through the motions of setting up an app to get the token and have the following:
$fbData = json_decode(file_get_contents('https://graph.facebook.com/myFacebookName?access_toke=MyAppId|MySecretToken'));
print_r($fbData);
It seems to only be returning objects:
stdClass Object ( [name] => My Facebook Name [id] => id number )
And that is all, giving me nothing to parse through. The name and id coming through are correct so there is a connection happening. Note that I have edited out some information so MyFacebookName and MyAppId|MySecretToken are actually populated with the correct info. Any ideas how to get the full JSON list to grab page likes? Am I missing something?
UPDATE
Thanks to Tobi and further reading the graph api, documentation I was able to get the number of likes with with following:
$fbData = json_decode(file_get_contents('https://graph.facebook.com/name?fields=likes&access_token=appId|accessToken'));
<?php echo number_format($fbData->likes);?>
You need to specifically request the fields you want in the response. In your case this would be
https://graph.facebook.com/myFacebookName?fields=id,name,likes&access_toke=MyAppId|MySecretToken
I don't understand why you say there "nothing to parse", because the object IS returned and can be used. So what's the problem?
Using echo $fbData['likes'] should give you the number of likes.
See
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.4#fields
https://developers.facebook.com/docs/graph-api/reference/page#Reading
I would like to create a campaign using Facebook API. I tried to run all available example without success.
First of all I created an App in order to have a APP_ID and a APP_SECRET.
I did all the procedure to add my Ad_account following the tutorial.
I downloaded all the SDK to facilitate Facebook API use like:
facebook-php-ads-sdk and run adgroup_creation.php and curl_log.php with my data, without success.
facebook-php-sdk-v4 I suppose it is less specific than the previous one.
Multi-Product Ads with the Facebook Marketing POST -> developers.facebook.com/ads/blog/post/2015/03/26/creating-multi-product-ads/
the developers reference -> developers.facebook.com/docs/reference/php/4.0.0
I used "Composer" to get all dependency.
In all this case I had problem to create a campaign using more or less this code:
$campaign = new \FacebookAds\Object\AdCampaign(null,"act_$ACCOUNT_ID");
$campaign->setData(array(
AdCampaignFields::NAME => 'My First Campaign',
AdCampaignFields::OBJECTIVE => AdObjectives::WEBSITE_CLICKS,
AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED ));
// PROBLEM is Here
$campaign->create();
Any help? How can I get a more useful error?
It's difficult to help without knowing the exact error. However, you could try this: before creating your campaign, initialize the API using:
Api::init(<your_app_id>, <your_ap_secret>, <your_token>);
(You need to load FacebookAds\Api to use this function).
I'm using the SalesForce PHP Toolkit and getting a connection just fine. But when I use any of the example code - see here
INVALID_FIELD: No such column '' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
I might just be struggling to find the answer because Google won't let me search for ''
The environment is CentOS 6 with PHP 5.3.
I just created an account here to answer this question. It took me all day long to find out this bug in PHP Toolkit. The problem is caused by the "fieldsToNull" property. I read an approx. solution here that gave me an idea where to look for the solution.
So a correct example would be:
$fields = array('LastName' => 'Doe');
$sObject = new SObject();
$sObject->fields = $fields;
$sObject->fieldsToNull = NULL;//this is the solution! :)
$sObject->type = 'Contact';
Then, proceed as usual with the remaining part of the examples of the PHP Toolkit. It worked fine with my Partner WSDL+Developer SF Account.
Hope it helps!
I'm playing around with the Amazon developer's API and I'm not getting anything.
Here is my code. I am using echo to see if anything is happening and all I am getting is a blank webpage. I expected the array of search results to be echoed.
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once('Zend/Service/Amazon.php');
$amazon = new Zend_Service_Amazon('AKIAJQBYUXIFWUIX6W6A', 'US', 'YGV9zePfKejV6C3dpaP/NtnhjGLfWQsccdGSSL50');
$results = $amazon->itemSearch(array('SearchIndex' => 'Books',
'Keywords' => 'php'));
foreach ($results as $result) {
echo $result->Title . '<br />';
}
?>
getting a blank page still
Your page is blank because you are no getting any results:
This is the $results dump using your published code:
Amazon object(Zend_Service_Amazon_ResultSet)#103 (4) {
["_results":protected] => object(DOMNodeList)#105 (0) {
}
["_dom":protected] => object(DOMDocument)#101 (0) {
}
["_xpath":protected] => object(DOMXPath)#104 (0) {
}
["_currentIndex":protected] => int(0)
}
There are several issues to resolve to make this work, the biggest one being this:
The following changes will take effect on 11/1/2011: Associate Tag Parameter: Every request made to the API should include
a valid Associate Tag. Any request that does not contain a valid
Associate Tag will be rejected with an appropriate error message. For
details on the Associate Tag parameter, please refer to our Developer
guide.
Currently the constructor for Zend_Service_Amazon does not include the Associate Tag parameter and the _prepareOptions() method does not set the option.
I'm sure someone has a fix for this, otherwise it's time to dig in and extend... Good Luck
Amazon Product Advertising API
Changes to Product Advertising API
The Zend_Service_Amazon is out of date and uses old WSDL.
see http://zendframework.com/issues/browse/ZF-12046
wait for 1.12 or use the provided batch file.
I am using the PHP SDK to try and post a simple action using the Graph API.
I have set up an object called 'Competition' and an action called 'Enter'. As such, a user enters a competition.
My code is like so:
try {
$statusUpdate = $this->data['facebook']->api('/me/lovepoppycompetition:enter', 'post', array(
'competition' => 'https://apps.facebook.com/lovepoppycompetition/'
));
echo '<pre>SUCCESS: '.print_r($statusUpdate, true).'</pre>';
} catch(FacebookApiException $e) {
echo '<pre>FAILED: '.print_r($e, true).'</pre>';
}
I am getting an error returned (FacebookApiException):
(#100) At least one reference object must be specified
I'm not really sure why, especially as I am using this code (with different objects/actions) on another app with no issues just fine.
It might be worth noting that I haven't submitted the action, although I don't think I have to for it to work for me?
Thanks in advance.
I think the problem lies with you redirecting the action back to your facebook application. You should create a competition page on your website, and use that to redirect users back to your website.
Make sure you use the correct og tags on the redirect page.
This was caused by a FB bug, which is now resolved