小编Dan*_*iel的帖子

为什么使用CURL的这个函数适用于某些URL而不适用于其他URL?

我正在用PHP编写一个聚合来自其他各种网站的数据的网站.我有一个函数'returnPageSource',它接受一个URL并从该URL返回html作为字符串.

function returnPageSource($url){
    $ch = curl_init();
    $timeout = 5;   // set to zero for no timeout       

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);     // means the page is returned
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOUT_CONNECTTIMEOUT, $timeout); // how long to wait to connect
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);     // follow redirects
    //curl_setopt($ch, CURLOPT_HEADER, False);          // only request body

    $fileContents = curl_exec($ch); // $fileContents contains the html source of the required website
    curl_close($ch);

    return $fileContents;
}
Run Code Online (Sandbox Code Playgroud)

这适用于我需要的一些网站,如 http://atensembl.arabidopsis.info/Arabidopsis_thaliana_TAIR/unisearch?species=Arabidopsis_thaliana_TAIR;idx=;q=At5g02310,但不适用于其他网站,如http://www.bar .utoronto.ca/efp/cgi-bin/efpWeb.cgi?dataSource = Chemical&modeInput = Absolute&primaryGene = At5g02310&orthoListOn = …

php curl

4
推荐指数
1
解决办法
2903
查看次数

在Salesforce中创建Apex测试方法"未定义构造函数"

我编写了一个在用户按下按钮时执行的顶点类.它将当前数据保存到日志中,检查它们当前所在的页面并重新加载它(因此它们显示为记录器的空白实例).我目前正在尝试为此类编写测试方法并收到此错误:"编译错误:未定义构造函数:[Logger_Extend].()在第45行第38列"(第45行是这一行"Logger_Extend controller = new Logger_Extend ();").

这是相关的代码.对于我做错了什么,有没有人有任何想法?

public class Logger_Extend {

private final RCA_Logger__c Log;

public Logger_Extend (ApexPages.StandardController
                            stdController) {
   Log = (RCA_Logger__c)stdController.getRecord();
}

 public PageReference XX() {

// Add the account to the database.   
insert Log; 

// Send the user back to current page.  

  PageReference pageRef = ApexPages.currentPage();
  pageRef.setRedirect(true);
  return pageRef;
}

static testMethod void myTest() {

      Logger_Extend controller = new Logger_Extend();
      PageReference pageRef = ApexPages.currentPage();
      System.assert(controller.XX() == pageRef);

   }
Run Code Online (Sandbox Code Playgroud)

}

java salesforce apex-code

1
推荐指数
1
解决办法
5404
查看次数

标签 统计

apex-code ×1

curl ×1

java ×1

php ×1

salesforce ×1